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/entry.routes.js b/backend/routes/entry.routes.js index a477b75..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 @@ -65,13 +68,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); @@ -83,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) => { @@ -172,7 +218,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/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/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/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 47a6df5..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: 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. .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/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/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-routing.module.ts b/frontend/src/app/app-routing.module.ts index 4a068b9..f8b6c53 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -1,26 +1,30 @@ 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'; 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' }, { path: 'home', component: HomeComponent }, - { path: 'search', component: SearchComponent }, + { path: 'search', component: SearchPageComponent }, { path: 'popular', component: PopularComponent }, { path: 'trending', component: TrendingComponent }, { 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.component.ts b/frontend/src/app/app.component.ts index 8f665bb..d5e84d5 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 = 'Showy'; + @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(); } } diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index f7c9833..2efae5e 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'; @@ -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({ @@ -53,11 +52,10 @@ import { ToastrModule } from 'ngx-toastr'; HomeComponent, PopularComponent, TrendingComponent, - SearchComponent, + SearchPageComponent, LibraryComponent, FavoritComponent, WatchlistComponent, - SettingsComponent, // ? temp shared components MainCardComponent, 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
+ + - \ 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 @@
-
+ +
+ +
+ + -
-
+ --> + 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/features/entry/entry-page/entry-page.component.css b/frontend/src/app/features/entry/entry-page/entry-page.component.css index 47be8ba..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 @@ -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,25 @@ } .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; +} + +.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..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 @@ -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 - + +
    @@ -72,7 +123,6 @@
    -
    @@ -113,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

    @@ -149,57 +203,71 @@ -
    -

    Watch History

    - - - - - - - - - - - - - - - - - +
    +

    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 }} + +
    + +
    + +
    +
    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..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 @@ -18,6 +18,8 @@ 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'; +import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component'; @Component({ selector: 'app-entry-page', @@ -125,51 +127,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 +144,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', @@ -359,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; @@ -418,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/features/home/home.component.html b/frontend/src/app/features/home/home.component.html index 4429cc3..35cda1b 100644 --- a/frontend/src/app/features/home/home.component.html +++ b/frontend/src/app/features/home/home.component.html @@ -297,7 +297,7 @@

    Movies

    {{this.watchCount.moviesTotal}}

    -

    16.5%55.21 USD

    +
    @@ -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/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; } 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/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/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/components/modals/seen-modal/seen-modal.component.ts b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts index 0711366..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 == 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 { 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; +} 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/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/images/default/default-logo.png b/frontend/src/assets/images/default/default-logo.png new file mode 100644 index 0000000..aebb1a8 Binary files /dev/null and b/frontend/src/assets/images/default/default-logo.png differ diff --git a/frontend/src/assets/sass/main.css b/frontend/src/assets/sass/main.css index 5bad7a5..818042c 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; } @@ -528,10 +528,10 @@ footer { .main-wrapper { position: relative; - height: calc(100vh - 70px); + height: calc(100vh - 50px); /* 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..f940d07 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); @@ -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 { @@ -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; 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', +}; 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