Front/Back: add entry settings modal
This commit is contained in:
1 parent
8724a96b81
commit
625ec3367e
15 files changed
+334
-57
No files matched your search
@@ -6,6 +6,7 @@ sequelize.log
|
||||
showy.log
|
||||
|
||||
# Compiled output
|
||||
/rock
|
||||
/dist
|
||||
/dist_exe
|
||||
/dist_electron
|
||||
|
||||
@@ -5,14 +5,14 @@ const Entry = sequelize.define("entry",
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
title: { type: DataTypes.STRING(100) },
|
||||
title: { type: DataTypes.STRING(500) },
|
||||
original_title: { type: DataTypes.STRING(100), field: 'original_title' },
|
||||
release_date: { type: DataTypes.DATE, field: 'release_date' },
|
||||
release_status: { type: DataTypes.STRING(50), field: 'release_status' },
|
||||
runtime: { type: DataTypes.INTEGER },
|
||||
|
||||
tagline: { type: DataTypes.STRING(200) },
|
||||
storyline: { type: DataTypes.STRING(2000) },
|
||||
storyline: { type: DataTypes.STRING(3000) },
|
||||
country: { type: DataTypes.STRING(30) },
|
||||
|
||||
certification: { type: DataTypes.INTEGER },
|
||||
@@ -23,6 +23,9 @@ const Entry = sequelize.define("entry",
|
||||
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
favorit: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
hidden: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
showInCalendar: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'show_in_calendar' },
|
||||
autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'auto_sync' },
|
||||
|
||||
note: { type: DataTypes.STRING(2000) },
|
||||
|
||||
is_tvseries: { type: DataTypes.BOOLEAN, field: 'is_tvseries' },
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
const express = require('express');
|
||||
const entryRouter = express.Router();
|
||||
const path = require('path');
|
||||
|
||||
const { fetchEntryData, fetchCollectionData } = require('../services/tmdbService');
|
||||
const { saveEntry, refrechEntry, SyncSeriesData } = require('../services/models-services/entryService');
|
||||
const { bulkImportMovies, bulkImportTmdb, bulkImportEpisodes } = require('../services/importerService');
|
||||
const { entryPicturesUpload } = require('../services/mutlerStorageLocations');
|
||||
const { generatePreview, doGeneratePreview } = require('../services/mediaService');
|
||||
const { doGeneratePreview } = require('../services/mediaService');
|
||||
|
||||
const { Sequelize } = require('sequelize');
|
||||
const Entry = require('../models/Entry');
|
||||
@@ -17,14 +16,13 @@ const EntrySeen = require('../models/EntrySeen');
|
||||
const Season = require('../models/Season');
|
||||
const Media = require('../models/Media');
|
||||
const Episode = require('../models/Episode');
|
||||
const UserCollection = require('../models/Collection');
|
||||
const Collection = require('../models/Collection');
|
||||
const { upsertOfficialCollection } = require('../services/models-services/collectionService');
|
||||
const { logToFile } = require('../services/logService');
|
||||
|
||||
// ! /entries
|
||||
// * GET - ALL ENTRIES
|
||||
entryRouter.get('/', async (req, res) => {
|
||||
const { page, pageSize } = req.body;
|
||||
|
||||
const entries = await Entry.findAll({
|
||||
include: [
|
||||
@@ -80,7 +78,7 @@ entryRouter.get('/:id', async (req, res) => {
|
||||
{ model: Season, as: 'seasons' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{
|
||||
model: UserCollection, as: 'collections',
|
||||
model: Collection, as: 'collections',
|
||||
include: [
|
||||
{ model: Media, as: 'medias' }
|
||||
]
|
||||
@@ -98,16 +96,17 @@ entryRouter.get('/:id', async (req, res) => {
|
||||
[{ 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);
|
||||
const entryObjectData = entry.get({ plain: true });
|
||||
const genres = entryObjectData.genres.map(genre => genre.name);
|
||||
|
||||
entryData.genres = genres;
|
||||
entryObjectData.genres = genres;
|
||||
|
||||
res.status(200).json(entryData);
|
||||
res.status(200).json(entryObjectData);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
@@ -154,7 +153,7 @@ entryRouter.get('/:id/seasons', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// * POST - CREATE ENTRY
|
||||
// * POST - FETCH AND CREATE USING TMDB ID
|
||||
entryRouter.post('/', async (req, res) => {
|
||||
const { tmdb_id, is_tvserie } = req.body;
|
||||
|
||||
@@ -213,7 +212,7 @@ entryRouter.post('/bulk-import-episodes-seen', async (req, res) => {
|
||||
// * PUT - ENTRY UPDATE
|
||||
entryRouter.put('/:id', async (req, res) => {
|
||||
const { id } = req.params;
|
||||
const { favorit, hidden, watchlist } = req.body;
|
||||
const { entryData } = req.body;
|
||||
|
||||
// ? checking if the provied id is valid
|
||||
const oldEntry = await Entry.findByPk(id);
|
||||
@@ -222,43 +221,66 @@ entryRouter.put('/:id', async (req, res) => {
|
||||
return res.status(404).json({ message: `Entry with the provided id was not found` });
|
||||
|
||||
// ? updating
|
||||
await oldEntry.update({
|
||||
favorit: favorit,
|
||||
watchlist: watchlist,
|
||||
hidden: hidden
|
||||
});
|
||||
await oldEntry.update(entryData);
|
||||
|
||||
// ? returning a new entry with updated values
|
||||
let includes = [
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['name'],
|
||||
through: {
|
||||
attributes: []
|
||||
}
|
||||
}
|
||||
];
|
||||
// let includes = [
|
||||
// { model: EntryId, as: 'entryId' },
|
||||
// { model: EntryRating, as: 'entryRating' },
|
||||
// { model: EntrySeen, as: 'entrySeen' },
|
||||
// { model: Media, as: 'medias' },
|
||||
// {
|
||||
// model: Genre,
|
||||
// as: 'genres',
|
||||
// attributes: ['name'],
|
||||
// through: {
|
||||
// attributes: []
|
||||
// }
|
||||
// }
|
||||
// ];
|
||||
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
// if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
// const updatedEntry = await Entry.findByPk(id, {
|
||||
// include: includes,
|
||||
// order: [
|
||||
// [{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
// ]
|
||||
// });
|
||||
|
||||
const updatedEntry = await Entry.findByPk(id, {
|
||||
include: includes,
|
||||
include: [
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{
|
||||
model: Collection, as: 'collections',
|
||||
include: [
|
||||
{ model: Media, as: 'medias' }
|
||||
]
|
||||
},
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['name'], // Only fetch the genre ID
|
||||
through: {
|
||||
attributes: [] // Do not fetch any attributes from the join table
|
||||
}
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
});
|
||||
|
||||
const entryData = updatedEntry.get({ plain: true });
|
||||
const genres = entryData.genres.map(genre => genre.name);
|
||||
const entryObjectData = updatedEntry.get({ plain: true });
|
||||
const genres = entryObjectData.genres.map(genre => genre.name);
|
||||
|
||||
entryData.genres = genres;
|
||||
entryObjectData.genres = genres;
|
||||
|
||||
res.status(201).json(entryData);
|
||||
res.status(201).json(entryObjectData);
|
||||
});
|
||||
|
||||
// * GET - REQUEST ENTRY REFRECH
|
||||
@@ -289,7 +311,7 @@ entryRouter.get('/:id/fetch-collection', async (req, res, next) => {
|
||||
if (entryData.belongs_to_collection) {
|
||||
let collectionData = entryData.belongs_to_collection;
|
||||
|
||||
const [oldCollection, createdCollection] = await UserCollection.findOrCreate({
|
||||
const [oldCollection, createdCollection] = await Collection.findOrCreate({
|
||||
where: { tmdbId: collectionData.id },
|
||||
defaults: {
|
||||
name: collectionData.name,
|
||||
@@ -425,7 +447,8 @@ entryRouter.delete('/:entryId/media/:mediaId', async (req, res) => {
|
||||
if (media && media.isSelected) {
|
||||
let otherMedia = await Media.findOne({
|
||||
where: {
|
||||
entryId: media.entryId,
|
||||
mediaable: 'entry',
|
||||
mediaableId: media.mediaableId,
|
||||
type: media.type,
|
||||
isSelected: false
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ const { getEpisodesBetweenDates } = require('../services/models-services/episode
|
||||
const episodeRouter = express.Router();
|
||||
|
||||
// ! /episodes
|
||||
|
||||
episodeRouter.get('/month/:startDate/:endDate', async (req, res) => {
|
||||
const { startDate, endDate } = req.params;
|
||||
try {
|
||||
|
||||
@@ -24,20 +24,18 @@ export class EntryService {
|
||||
}
|
||||
|
||||
// get entry by id
|
||||
getEntryById(entryId: string) {
|
||||
getEntryById(entryId: number) {
|
||||
return this.http.get<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}`
|
||||
);
|
||||
}
|
||||
|
||||
// update entry
|
||||
updateEntry(entry: Entry) {
|
||||
updateEntry(entryId: number, entryData: any) {
|
||||
return this.http.put<Entry>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entry.id}`,
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}`,
|
||||
{
|
||||
favorit: entry.favorit,
|
||||
watchlist: entry.watchlist,
|
||||
hidden: entry.hidden,
|
||||
entryData: entryData,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -69,6 +67,12 @@ export class EntryService {
|
||||
);
|
||||
}
|
||||
|
||||
syncSeries() {
|
||||
return this.http.get<Entry[]>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/sync-series`
|
||||
);
|
||||
}
|
||||
|
||||
fetchEntryCollectionById(entryId: number) {
|
||||
return this.http.get<any>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryId}/fetch-collection`
|
||||
|
||||
@@ -7,6 +7,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { SeasonMainCardComponent } from './season-main-card/season-main-card.component';
|
||||
import { MediaModalComponent } from './media-modal/media-modal.component';
|
||||
import { MediaUploadModalComponent } from './media-upload-modal/media-upload-modal.component';
|
||||
import { EntrySettingsModalComponent } from './entry-settings-modal/entry-settings-modal.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -14,6 +15,7 @@ import { MediaUploadModalComponent } from './media-upload-modal/media-upload-mod
|
||||
SeasonMainCardComponent,
|
||||
MediaModalComponent,
|
||||
MediaUploadModalComponent,
|
||||
EntrySettingsModalComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button class="btn btn-icon-only-success wh-48" (click)="showAddToListModal()">
|
||||
<button class="btn btn-icon-only-success wh-48" (click)="addToCollectionModal()">
|
||||
<span class="material-symbols-outlined">
|
||||
playlist_add
|
||||
</span>
|
||||
@@ -172,6 +172,12 @@
|
||||
image
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button class="btn btn-icon-only-success wh-48" (click)="settingsModal()">
|
||||
<span class="material-symbols-outlined">
|
||||
settings
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- End Interraction buttons -->
|
||||
</div>
|
||||
@@ -291,7 +297,7 @@
|
||||
<h3>Belong to Collection(s)</h3>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-filter bg-transparent" type="button" style="cursor: pointer;"
|
||||
(click)="showAddToListModal()">
|
||||
(click)="addToCollectionModal()">
|
||||
<i class="bi bi-collection"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -23,6 +23,7 @@ import { EpisodeSeenModalComponent } from '../../../shared/components/modals/epi
|
||||
import { MediaModalComponent } from '../media-modal/media-modal.component';
|
||||
import { environment } from '../../../../environments/environment.prod';
|
||||
import { Collection } from '../../../shared/models/collection.model';
|
||||
import { EntrySettingsModalComponent } from '../entry-settings-modal/entry-settings-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-page',
|
||||
@@ -275,10 +276,14 @@ export class EntryPageComponent implements OnInit {
|
||||
toggleFavorite() {
|
||||
this.lockActions = true;
|
||||
this.entry.favorit = !this.entry.favorit;
|
||||
this.entryService.updateEntry(this.entry).subscribe({
|
||||
|
||||
const entryData = { favorit: this.entry.favorit };
|
||||
|
||||
this.entryService.updateEntry(this.entry.id, entryData).subscribe({
|
||||
next: (entry) => {
|
||||
// console.log(`Entry updated: `, entry);
|
||||
this.entry = entry;
|
||||
this.entry.isInLibrary = true;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Error updating entry: `, error);
|
||||
@@ -293,10 +298,14 @@ export class EntryPageComponent implements OnInit {
|
||||
toggleHidden() {
|
||||
this.lockActions = true;
|
||||
this.entry.hidden = !this.entry.hidden;
|
||||
this.entryService.updateEntry(this.entry).subscribe({
|
||||
|
||||
const entryData = { hidden: this.entry.hidden };
|
||||
|
||||
this.entryService.updateEntry(this.entry.id, entryData).subscribe({
|
||||
next: (entry) => {
|
||||
// console.log(`Entry updated: `, entry);
|
||||
this.entry = entry;
|
||||
this.entry.isInLibrary = true;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Error updating entry: `, error);
|
||||
@@ -308,7 +317,7 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
showAddToListModal() {
|
||||
addToCollectionModal() {
|
||||
if (this.entry) {
|
||||
const dialogRef = this.dialog.open(UserCollectionsModalComponent, {
|
||||
width: '400px',
|
||||
@@ -320,13 +329,24 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
// TODO update entry page collections
|
||||
// console.log('Modal Closed: ', result);
|
||||
this.entryService.getEntryById(this.entry.id).subscribe({
|
||||
next: (result) => {
|
||||
this.entry.collections = result.collections.map((c) => {
|
||||
c.mediasCount = c.medias.length;
|
||||
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
||||
|
||||
c.medias = [];
|
||||
return c;
|
||||
});
|
||||
result.collections;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getCollectionBackdropPath(collection: Collection) {
|
||||
console.log(`collection media:`, collection.medias);
|
||||
// console.log(`collection media:`, collection.medias);
|
||||
if (collection.medias && collection.medias.length != 0) {
|
||||
const backdrops = collection.medias.filter((m) => m.type == 'backdrop');
|
||||
if (backdrops.length != 0) {
|
||||
@@ -334,7 +354,7 @@ export class EntryPageComponent implements OnInit {
|
||||
(m) => m.type == 'backdrop' && m.isSelected
|
||||
);
|
||||
|
||||
console.log(selectedBackdrops);
|
||||
// console.log(selectedBackdrops);
|
||||
let selectedBackdrop;
|
||||
if (selectedBackdrops.length != 0) {
|
||||
selectedBackdrop = selectedBackdrops[0].path;
|
||||
@@ -374,6 +394,14 @@ export class EntryPageComponent implements OnInit {
|
||||
this.entryService.refrechEntryById(this.entry.id).subscribe({
|
||||
next: (entry) => {
|
||||
this.entry = entry;
|
||||
this.entry.isInLibrary = true;
|
||||
this.entry.collections = this.entry.collections.map((c) => {
|
||||
c.mediasCount = c.medias.length;
|
||||
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
||||
|
||||
c.medias = [];
|
||||
return c;
|
||||
});
|
||||
// console.log(`Entry refreched: `, entry);
|
||||
this.toastr.success(`Movie refreshed successfuly.`, 'Success', {
|
||||
tapToDismiss: true,
|
||||
@@ -551,7 +579,11 @@ export class EntryPageComponent implements OnInit {
|
||||
next: () => {
|
||||
// console.log(`Episode seen deleted.`);
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
// this.getEpisodesSeenHistory();
|
||||
this.seenHistory = this.seenHistory.filter(
|
||||
(eps) => eps.id != episodeSeen.id
|
||||
);
|
||||
this.filterEpisodesSeenHistory();
|
||||
|
||||
// ? Updating the episodes seen progress bar in the season card
|
||||
// ? by fetching a new updated episodes list
|
||||
@@ -684,6 +716,29 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
settingsModal() {
|
||||
const dialogRef = this.dialog.open(EntrySettingsModalComponent, {
|
||||
width: '800px',
|
||||
height: '600px',
|
||||
minHeight: '50%',
|
||||
panelClass: 'media-dialog-container',
|
||||
data: {
|
||||
entry: this.entry,
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
this.entry.watchlist = result.entry.watchlist;
|
||||
this.entry.favorit = result.entry.favorit;
|
||||
this.entry.hidden = result.entry.hidden;
|
||||
this.entry.showInCalendar = result.entry.showInCalendar;
|
||||
this.entry.autoSync = result.entry.autoSync;
|
||||
} else {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// * getters
|
||||
get status() {
|
||||
return this.entry.status;
|
||||
@@ -759,4 +814,12 @@ export class EntryPageComponent implements OnInit {
|
||||
if (!this.entry.is_tvseries) return 'This is a movie';
|
||||
return 'sooon';
|
||||
}
|
||||
|
||||
fetchEntry() {
|
||||
this.entryService.getEntryById(this.entry.id).subscribe({
|
||||
next: (result) => {
|
||||
this.entry = { ...result, isInLibrary: true };
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
+40
@@ -0,0 +1,40 @@
|
||||
<div class="card border-top border-3 border-primary rounded-0 media-dialog-main mb-0">
|
||||
<div class="modal-header card-header py-3 px-4">
|
||||
<h5 class="mb-0 text-primary">Entry Settings</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" (click)="onClose()"></button>
|
||||
</div>
|
||||
<div class="card-body p-4 pt-0">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<form class="row g-3" [formGroup]="entryForm">
|
||||
<div class="col-md-12">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="favorit" formControlName="favorit" class="form-check-input">
|
||||
<label for="favorit" class="form-check-label">Favorit</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="hidden" formControlName="hidden" class="form-check-input">
|
||||
<label for="hidden" class="form-check-label">Hidden</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="showInCalendar" formControlName="showInCalendar" class="form-check-input">
|
||||
<label for="showInCalendar" class="form-check-label">Show in Calendar</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="watchlist" formControlName="watchlist" class="form-check-input">
|
||||
<label for="watchlist" class="form-check-label">Watchlist</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="autoSync" formControlName="autoSync" class="form-check-input">
|
||||
<label for="autoSync" class="form-check-label">Auto Sync</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 mt-3 d-flex justify-content-end gap-3">
|
||||
<button type="button" class="btn btn-primary px-4 rounded-0" (click)="onSubmit()">Confirm</button>
|
||||
<button type="button" class="btn btn-secondary px-4 rounded-0" (click)="onClose()">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { EntrySettingsModalComponent } from './entry-settings-modal.component';
|
||||
|
||||
describe('EntrySettingsModalComponent', () => {
|
||||
let component: EntrySettingsModalComponent;
|
||||
let fixture: ComponentFixture<EntrySettingsModalComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EntrySettingsModalComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EntrySettingsModalComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import {
|
||||
MatDialogRef,
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialog,
|
||||
} from '@angular/material/dialog';
|
||||
import { EntryService } from '../../../core/services/entry.service';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-settings-modal',
|
||||
templateUrl: './entry-settings-modal.component.html',
|
||||
styleUrls: ['./entry-settings-modal.component.css'],
|
||||
})
|
||||
export class EntrySettingsModalComponent implements OnInit {
|
||||
entryId!: number;
|
||||
entryForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<EntrySettingsModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private formBuilder: FormBuilder,
|
||||
private entryService: EntryService
|
||||
) {
|
||||
this.entryForm = this.formBuilder.group({
|
||||
watchlist: [null],
|
||||
favorit: [null],
|
||||
hidden: [null],
|
||||
showInCalendar: [null],
|
||||
autoSync: [null],
|
||||
});
|
||||
|
||||
if (this.data && this.data.entry) {
|
||||
this.entryForm.patchValue(this.data.entry);
|
||||
this.entryId = this.data.entry.id;
|
||||
} else {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
onSubmit() {
|
||||
const entryData = this.entryForm.value;
|
||||
|
||||
this.entryService.updateEntry(this.entryId, entryData).subscribe({
|
||||
next: (result) => {
|
||||
this.dialogRef.close({ entry: result });
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,9 @@ export interface Entry {
|
||||
watchlist: boolean;
|
||||
favorit: boolean;
|
||||
hidden: boolean;
|
||||
showInCalendar: boolean;
|
||||
autoSync: boolean;
|
||||
|
||||
note: string;
|
||||
|
||||
is_tvseries: boolean;
|
||||
@@ -47,6 +50,7 @@ export interface Entry {
|
||||
|
||||
// * front specific fields
|
||||
isInLibrary: boolean;
|
||||
isLocked: boolean;
|
||||
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
||||
Generated
+45
-1
@@ -59,6 +59,9 @@ importers:
|
||||
axios:
|
||||
specifier: ^1.6.8
|
||||
version: 1.7.5
|
||||
body-parser:
|
||||
specifier: ^1.20.3
|
||||
version: 1.20.3
|
||||
bootstrap:
|
||||
specifier: ^5.3.3
|
||||
version: 5.3.3(@popperjs/core@2.11.8)
|
||||
@@ -71,6 +74,9 @@ importers:
|
||||
flatpickr:
|
||||
specifier: ^4.6.13
|
||||
version: 4.6.13
|
||||
form-data:
|
||||
specifier: ^4.0.0
|
||||
version: 4.0.0
|
||||
html2canvas:
|
||||
specifier: ^1.4.1
|
||||
version: 1.4.1
|
||||
@@ -110,6 +116,9 @@ importers:
|
||||
tslib:
|
||||
specifier: ^2.3.0
|
||||
version: 2.7.0
|
||||
uuid:
|
||||
specifier: ^10.0.0
|
||||
version: 10.0.0
|
||||
zone.js:
|
||||
specifier: ~0.14.3
|
||||
version: 0.14.10
|
||||
@@ -2176,6 +2185,10 @@ packages:
|
||||
resolution: {integrity: sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
|
||||
body-parser@1.20.3:
|
||||
resolution: {integrity: sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
|
||||
bonjour-service@1.2.1:
|
||||
resolution: {integrity: sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw==}
|
||||
|
||||
@@ -4208,6 +4221,10 @@ packages:
|
||||
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
qs@6.13.0:
|
||||
resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
queue-microtask@1.2.3:
|
||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||
|
||||
@@ -4946,6 +4963,10 @@ packages:
|
||||
utrie@1.0.2:
|
||||
resolution: {integrity: sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==}
|
||||
|
||||
uuid@10.0.0:
|
||||
resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==}
|
||||
hasBin: true
|
||||
|
||||
uuid@8.3.2:
|
||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
hasBin: true
|
||||
@@ -7973,6 +7994,23 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
body-parser@1.20.3:
|
||||
dependencies:
|
||||
bytes: 3.1.2
|
||||
content-type: 1.0.5
|
||||
debug: 2.6.9
|
||||
depd: 2.0.0
|
||||
destroy: 1.2.0
|
||||
http-errors: 2.0.0
|
||||
iconv-lite: 0.4.24
|
||||
on-finished: 2.4.1
|
||||
qs: 6.13.0
|
||||
raw-body: 2.5.2
|
||||
type-is: 1.6.18
|
||||
unpipe: 1.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
bonjour-service@1.2.1:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.3
|
||||
@@ -9463,7 +9501,7 @@ snapshots:
|
||||
karma@6.4.4:
|
||||
dependencies:
|
||||
'@colors/colors': 1.5.0
|
||||
body-parser: 1.20.2
|
||||
body-parser: 1.20.3
|
||||
braces: 3.0.3
|
||||
chokidar: 3.6.0
|
||||
connect: 3.7.0
|
||||
@@ -10224,6 +10262,10 @@ snapshots:
|
||||
dependencies:
|
||||
side-channel: 1.0.6
|
||||
|
||||
qs@6.13.0:
|
||||
dependencies:
|
||||
side-channel: 1.0.6
|
||||
|
||||
queue-microtask@1.2.3: {}
|
||||
|
||||
quick-lru@5.1.1: {}
|
||||
@@ -11027,6 +11069,8 @@ snapshots:
|
||||
dependencies:
|
||||
base64-arraybuffer: 1.0.2
|
||||
|
||||
uuid@10.0.0: {}
|
||||
|
||||
uuid@8.3.2: {}
|
||||
|
||||
validate-npm-package-license@3.0.4:
|
||||
|
||||
Reference in new issue
Block a user