add media page + backend + minor changes to media related stuff & sidebar
This commit is contained in:
1 parent
c46309e458
commit
eba9721a3c
20 files changed
+597
-73
No files matched your search
@@ -16,13 +16,20 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'discover',
|
||||
loadChildren: () =>
|
||||
import('./features/discover/discover.module').then((m) => m.DiscoverModule),
|
||||
import('./features/discover/discover.module').then(
|
||||
(m) => m.DiscoverModule
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'library',
|
||||
loadChildren: () =>
|
||||
import('./features/library/library.module').then((m) => m.LibraryModule),
|
||||
},
|
||||
{
|
||||
path: 'media',
|
||||
loadChildren: () =>
|
||||
import('./features/media/media.module').then((m) => m.MediaModule),
|
||||
},
|
||||
{ path: 'favorit', component: FavoritComponent },
|
||||
{ path: 'watchlist', component: WatchlistComponent },
|
||||
{
|
||||
|
||||
@@ -83,6 +83,15 @@
|
||||
<div class="menu-title">Collections</div>
|
||||
</a>
|
||||
</li>
|
||||
<li routerLink="/media" routerLinkActive="mm-active">
|
||||
<a>
|
||||
<div class="parent-icon"><span class="material-symbols-outlined">
|
||||
filter
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-title">Media</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="menu-label">Other</li>
|
||||
<li routerLink="/calendar" routerLinkActive="mm-active">
|
||||
@@ -105,26 +114,17 @@
|
||||
<!--end navigation-->
|
||||
</div>
|
||||
<div class="sidebar-bottom gap-4">
|
||||
<div class="dark-mode">
|
||||
<a href="javascript:;" class="footer-icon dark-mode-icon" (click)="toggleTheme()">
|
||||
<i class="material-icons-outlined">dark_mode</i>
|
||||
<div class="btn-toggle" (click)="toggleSidebar()">
|
||||
<a class="dropdown-toggle dropdown-toggle-nocaret footer-icon" href="avascript:;" data-bs-toggle="dropdown">
|
||||
<i class="material-icons-outlined">menu</i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="dropdown dropup-center dropup dropdown-laungauge">
|
||||
<a class="dropdown-toggle dropdown-toggle-nocaret footer-icon" href="avascript:;" data-bs-toggle="dropdown"><img
|
||||
src="assets/images/county/02.png" width="22" alt="">
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item d-flex align-items-center py-2" href="javascript:;"><img
|
||||
src="assets/images/county/01.png" width="20" alt=""><span class="ms-2">English</span></a>
|
||||
</li>
|
||||
<li><a class="dropdown-item d-flex align-items-center py-2" href="javascript:;"><img
|
||||
src="assets/images/county/03.png" width="20" alt=""><span class="ms-2">French</span></a>
|
||||
</li>
|
||||
<li><a class="dropdown-item d-flex align-items-center py-2" href="javascript:;"><img
|
||||
src="assets/images/county/06.png" width="20" alt=""><span class="ms-2">Spanish</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="dark-mode">
|
||||
<a href="javascript:;" class="footer-icon dark-mode-icon" (click)="toggleTheme()">
|
||||
<i class="material-icons-outlined">dark_mode</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown dropup-center dropup dropdown-help">
|
||||
<a class="footer-icon dropdown-toggle dropdown-toggle-nocaret option" href="javascript:;"
|
||||
|
||||
@@ -30,4 +30,8 @@ export class SidebarComponent implements AfterViewInit {
|
||||
toggleTheme() {
|
||||
this.themeService.toggleTheme();
|
||||
}
|
||||
|
||||
toggleSidebar() {
|
||||
this.toggleService.toggleSidebar();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../../environments/environment.prod';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Media } from '../../shared/models/media.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CustomMediaService {
|
||||
private backend_apiUrl = environment.API_URL;
|
||||
private apiAction = 'custom-media';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
fetchCustomMedia(): Observable<Media[]> {
|
||||
return this.http.get<Media[]>(`${this.backend_apiUrl}/${this.apiAction}`);
|
||||
}
|
||||
}
|
||||
@@ -21,20 +21,16 @@
|
||||
|
||||
.media-dialog-main #posters .card-img-top {
|
||||
height: auto;
|
||||
/* Height should adjust to maintain aspect ratio */
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 3;
|
||||
/* Using the aspect-ratio property to specify a 2:3 ratio */
|
||||
object-fit: cover;
|
||||
/* Crop to cover the area of the container */
|
||||
}
|
||||
|
||||
/* Banner images */
|
||||
.media-dialog-main #banners .card-img-top {
|
||||
/* backdrops images */
|
||||
.media-dialog-main #backdrops .card-img-top {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
aspect-ratio: 8 / 3;
|
||||
/* An example ratio for wide banners */
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
@@ -43,24 +39,25 @@
|
||||
height: auto;
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 1;
|
||||
/* More wide than tall for logos */
|
||||
object-fit: contain;
|
||||
/* Ensure the entire logo is visible */
|
||||
}
|
||||
|
||||
|
||||
|
||||
.media-dialog-main .card .card-img-top {
|
||||
display: block;
|
||||
/* Ensure images are block elements to fill space correctly */
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
color: var(--shz-blue-1);
|
||||
}
|
||||
|
||||
.add-btn:hover {
|
||||
color: var(--shz-blue-default);
|
||||
}
|
||||
|
||||
/* ! media hover buttons */
|
||||
.image-hover-container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
/* Ensures no overflow outside the container */
|
||||
}
|
||||
|
||||
.image-hover-container img {
|
||||
@@ -68,10 +65,8 @@
|
||||
display: block;
|
||||
transition: transform 0.3s ease;
|
||||
transform-origin: center;
|
||||
/* Ensures scaling is centered */
|
||||
}
|
||||
|
||||
|
||||
.image-hover-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -79,7 +74,6 @@
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
/* Semi-transparent overlay */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -92,19 +86,21 @@
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
.image-hover-container:hover img {
|
||||
/* transform: scale(1.05); */
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
/* Adjust size as needed */
|
||||
}
|
||||
|
||||
.btn-icon:hover {
|
||||
color: var(--shz-gold-1);
|
||||
.btn-icon-delete:hover {
|
||||
color: var(--shz-red-danger);
|
||||
}
|
||||
|
||||
.btn-icon-select:hover {
|
||||
color: var(--shz-blue-default);
|
||||
}
|
||||
|
||||
.btn-icon-expand:hover {
|
||||
color: var(--shz-green-success);
|
||||
}
|
||||
@@ -12,37 +12,40 @@
|
||||
role="tab" aria-controls="posters" aria-selected="true" (click)="setTab('poster')">Posters</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="banners-tab" data-bs-toggle="tab" data-bs-target="#banners" type="button"
|
||||
role="tab" aria-controls="banners" aria-selected="false" (click)="setTab('backdrop')">Banners</button>
|
||||
<button class="nav-link" id="backdrops-tab" data-bs-toggle="tab" data-bs-target="#backdrops" type="button"
|
||||
role="tab" aria-controls="backdrops" aria-selected="false" (click)="setTab('backdrop')">Backdrops</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="logos-tab" data-bs-toggle="tab" data-bs-target="#logos" type="button" role="tab"
|
||||
aria-controls="logos" aria-selected="false"(click)="setTab('logo')">Logos</button>
|
||||
aria-controls="logos" aria-selected="false" (click)="setTab('logo')">Logos</button>
|
||||
</li>
|
||||
</div>
|
||||
<li class="nav-item">
|
||||
<button class="btn btn-primary rounded-0 p-1 bg-transparent border-0" type="button" (click)="openUploadModal()">
|
||||
<span class="material-symbols-outlined">
|
||||
<button class="btn btn-primary rounded-0 p-1 bg-transparent border-0 add-btn d-flex align-items-center"
|
||||
type="button" (click)="openUploadModal()">
|
||||
<span class="material-symbols-outlined me-1">
|
||||
add_photo_alternate
|
||||
</span>
|
||||
Add An Image
|
||||
</button>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="mediaTabContent">
|
||||
<div class="tab-pane fade show active" id="posters" role="tabpanel" aria-labelledby="posters-tab">
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="row row-cols-1 row-cols-md-4 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('poster')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('/posters/' + media.path)" class="card-img-top" alt="Media Image">
|
||||
<img [src]="getPath('posters', media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon" (click)="deleteMedia(media.id)">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media.id)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon" (click)="selectMedia(media)">
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon" (click)="expandMedia(media)">
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -50,20 +53,42 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="banners" role="tabpanel" aria-labelledby="banners-tab">
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="tab-pane fade" id="backdrops" role="tabpanel" aria-labelledby="backdrops-tab">
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('backdrop')">
|
||||
<div class="card">
|
||||
<img [src]="getPath('/backdrops/' + media.path)" class="card-img-top" alt="Poster">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('backdrops', media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media.id)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="logos" role="tabpanel" aria-labelledby="logos-tab">
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('logo')">
|
||||
<div class="card">
|
||||
<img [src]="getPath('/logos/' + media.path)" class="card-img-top" alt="Poster">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('logos', media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media.id)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,6 +28,7 @@ export class MediaModalComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
if (this.data && this.data.entry) {
|
||||
this.entry = this.data.entry;
|
||||
// console.log(this.entry.medias);
|
||||
} else {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
@@ -56,8 +57,8 @@ export class MediaModalComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getPath(mediaEnd: string) {
|
||||
return environment.API_URL + '/media/entries' + mediaEnd;
|
||||
getPath(fileType: string, filePath: string) {
|
||||
return `${environment.API_URL}/media/entries/${fileType}/preview/${filePath}`;
|
||||
}
|
||||
|
||||
setTab(tab: string) {
|
||||
@@ -81,10 +82,10 @@ export class MediaModalComponent implements OnInit {
|
||||
next: (result) => {
|
||||
this.entry.medias.forEach((m) => {
|
||||
if (m.type == media.type) {
|
||||
m.is_selected = false;
|
||||
m.isSelected = false;
|
||||
}
|
||||
if ((m.id = result.id)) {
|
||||
m.is_selected = true;
|
||||
m.isSelected = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -95,6 +96,7 @@ export class MediaModalComponent implements OnInit {
|
||||
}
|
||||
|
||||
expandMedia(media: any) {
|
||||
// Implementation to expand or view media in a larger view
|
||||
const fullSizePath = `${environment.API_URL}/media/entries/${media.type}s/original/${media.path}`;
|
||||
window.open(fullSizePath, '_blank');
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -21,8 +21,8 @@
|
||||
|
||||
</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()">Confirmer</button>
|
||||
<button type="button" class="btn btn-secondary px-4 rounded-0" (click)="onClose()">Annuler</button>
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
.media-dialog-container {
|
||||
height: 100%;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.media-dialog-main {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
height: 100% !important;
|
||||
overflow-y: auto !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
height: auto !important;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.media-dialog-main #posters .card-img-top {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 3;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* backdrops images */
|
||||
.media-dialog-main #backdrops .card-img-top {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
aspect-ratio: 8 / 3;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* Logo images */
|
||||
.media-dialog-main #logos .card-img-top {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 1;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.media-dialog-main .card .card-img-top {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
color: var(--shz-blue-1);
|
||||
}
|
||||
|
||||
.add-btn:hover {
|
||||
color: var(--shz-blue-default);
|
||||
}
|
||||
|
||||
/* ! media hover buttons */
|
||||
.image-hover-container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.image-hover-container img {
|
||||
width: 100%;
|
||||
display: block;
|
||||
transition: transform 0.3s ease;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.image-hover-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.image-hover-container:hover .image-hover-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.btn-icon-delete:hover {
|
||||
color: var(--shz-red-danger);
|
||||
}
|
||||
|
||||
.btn-icon-select:hover {
|
||||
color: var(--shz-blue-default);
|
||||
}
|
||||
|
||||
.btn-icon-expand:hover {
|
||||
color: var(--shz-green-success);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<div class="row row-cols-1 row-cols-md-1 row-cols-lg-1 row-cols-xl-1">
|
||||
<div class="col">
|
||||
<h6 class="mb-0 text-uppercase">Custom Uploaded Media</h6>
|
||||
<hr>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<ul class="nav nav-pills mb-3" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" data-bs-toggle="pill" href="#posters-content" role="tab" aria-selected="true">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="tab-icon"><i class="bi bi-file-image me-1 fs-6"></i></div>
|
||||
<div class="tab-title">Posters</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#backdrops-content" role="tab" aria-selected="false"
|
||||
tabindex="-1">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="tab-icon"><i class="bi bi-card-image me-1 fs-6"></i></div>
|
||||
<div class="tab-title">Backdrops</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#logos-content" role="tab" aria-selected="false"
|
||||
tabindex="-1">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="tab-icon"><i class="bi bi-alphabet-uppercase me-1 fs-6"></i>
|
||||
</div>
|
||||
<div class="tab-title">Logos</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="pills-tabContent">
|
||||
<div class="tab-pane fade active show" id="posters-content" role="tabpanel">
|
||||
<div class="row row-cols-4 row-cols-md-6 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('poster')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('posters' , media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="backdrops-content" role="tabpanel">
|
||||
<div class="row row-cols-2 row-cols-md-4 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('backdrop')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('backdrops', media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="logos-content" role="tabpanel">
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('logo')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('logos', media.path)" class="card-img-top" alt="Media Image">
|
||||
<div class="image-hover-overlay">
|
||||
<button class="btn btn-icon btn-icon-delete" (click)="deleteMedia(media)">
|
||||
<span class="material-symbols-outlined">delete</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-select" (click)="selectMedia(media)">
|
||||
<span class="material-symbols-outlined">check_circle</span>
|
||||
</button>
|
||||
<button class="btn btn-icon btn-icon-expand" (click)="expandMedia(media)">
|
||||
<span class="material-symbols-outlined">zoom_out_map</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 { MediaPageComponent } from './media-page.component';
|
||||
|
||||
describe('MediaPageComponent', () => {
|
||||
let component: MediaPageComponent;
|
||||
let fixture: ComponentFixture<MediaPageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MediaPageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MediaPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CustomMediaService } from '../../../core/services/custom-media.service';
|
||||
import { Media } from '../../../shared/models/media.model';
|
||||
import { environment } from '../../../../environments/environment.prod';
|
||||
import { EntryService } from '../../../core/services/entry.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-media-page',
|
||||
templateUrl: './media-page.component.html',
|
||||
styleUrls: ['./media-page.component.css'],
|
||||
})
|
||||
export class MediaPageComponent implements OnInit {
|
||||
customMedia: Media[] = [];
|
||||
tab: string = 'poster';
|
||||
|
||||
constructor(
|
||||
private customMediaService: CustomMediaService,
|
||||
private entryService: EntryService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.customMediaService.fetchCustomMedia().subscribe({
|
||||
next: (result) => {
|
||||
this.customMedia = result;
|
||||
console.log(result);
|
||||
},
|
||||
error: (error) => {},
|
||||
});
|
||||
}
|
||||
|
||||
filterMedia(type: string) {
|
||||
return this.customMedia.filter((media) => media.type == type);
|
||||
}
|
||||
|
||||
getPath(type: string, fileName: string) {
|
||||
return `${environment.API_URL}/media/entries/${type}/preview/${fileName}`;
|
||||
}
|
||||
|
||||
setTab(tab: string) {
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
deleteMedia(media: Media) {
|
||||
this.entryService.deleteEntryMedia(media.entry.id, media.id).subscribe({
|
||||
next: (result) => {
|
||||
// TODO add confirm modal
|
||||
this.customMedia = this.customMedia.filter((m) => m.id != media.id);
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
selectMedia(media: any) {
|
||||
this.entryService.selectEntryMedia(media.entry.id, media.id).subscribe({
|
||||
next: (result) => {
|
||||
this.customMedia.forEach((m) => {
|
||||
if (m.type == media.type) {
|
||||
m.isSelected = false;
|
||||
}
|
||||
if ((m.id = result.id)) {
|
||||
m.isSelected = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
expandMedia(media: any) {
|
||||
const fullSizePath = `${environment.API_URL}/media/entries/${media.type}s/original/${media.path}`;
|
||||
window.open(fullSizePath, '_blank');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { MediaPageComponent } from './media-page/media-page.component';
|
||||
|
||||
// ! /media
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: MediaPageComponent,
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class MediaRoutingModule {}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { MediaPageComponent } from './media-page/media-page.component';
|
||||
import { MediaRoutingModule } from './media-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
|
||||
MediaRoutingModule,
|
||||
],
|
||||
declarations: [MediaPageComponent],
|
||||
exports: [],
|
||||
})
|
||||
export class MediaModule {}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { Entry } from './entry.model';
|
||||
|
||||
export interface Media {
|
||||
id: number;
|
||||
|
||||
entry_id: number;
|
||||
entry: Entry;
|
||||
|
||||
type: string;
|
||||
path: string;
|
||||
|
||||
is_local: boolean;
|
||||
is_selected: boolean;
|
||||
isLocal: boolean;
|
||||
isSelected: boolean;
|
||||
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
||||
Reference in new issue
Block a user