F: implemented load media on scroll for media page
This commit is contained in:
1 parent
7f6202c897
commit
ec9e21dd0f
12 files changed
+240
-193
No files matched your search
-4
@@ -4,10 +4,6 @@
|
|||||||
<div class="ps-3">
|
<div class="ps-3">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb mb-0 p-0">
|
<ol class="breadcrumb mb-0 p-0">
|
||||||
<li class="breadcrumb-item">
|
|
||||||
<a href="javascript:;">
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Collections</li>
|
<li class="breadcrumb-item active" aria-current="page">Collections</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -4,11 +4,7 @@
|
|||||||
<div class="ps-3">
|
<div class="ps-3">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb mb-0 p-0">
|
<ol class="breadcrumb mb-0 p-0">
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item active" aria-current="page">{{displayType | titlecase}}</li>
|
||||||
<a href="javascript:;">
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Watchlist</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
<div class="ps-3">
|
<div class="ps-3">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb mb-0 p-0">
|
<ol class="breadcrumb mb-0 p-0">
|
||||||
<li class="breadcrumb-item">
|
|
||||||
<a href="javascript:;">
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { WatchlistComponent } from './watchlist-page/watchlist.component';
|
|||||||
import { EntriesDisplayComponent } from './entries-display/entries-display.component';
|
import { EntriesDisplayComponent } from './entries-display/entries-display.component';
|
||||||
import { FavoritComponent } from './favorit-page/favorit.component';
|
import { FavoritComponent } from './favorit-page/favorit.component';
|
||||||
import { MultiSelectModule } from 'primeng/multiselect';
|
import { MultiSelectModule } from 'primeng/multiselect';
|
||||||
|
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -26,6 +27,8 @@ import { MultiSelectModule } from 'primeng/multiselect';
|
|||||||
|
|
||||||
MultiSelectModule,
|
MultiSelectModule,
|
||||||
DragDropModule,
|
DragDropModule,
|
||||||
|
|
||||||
|
NgbDropdownModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
EntriesDisplayComponent,
|
EntriesDisplayComponent,
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/* ! 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,18 @@
|
|||||||
|
<div class="row row-cols-4 row-cols-md-6 g-4">
|
||||||
|
<div class="col" *ngFor="let media of mediaToDisplay">
|
||||||
|
<div class="card image-hover-container">
|
||||||
|
<img [src]="getPath(media.type+'s' , media)" 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>
|
||||||
@@ -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 { MediaGridComponent } from './media-grid.component';
|
||||||
|
|
||||||
|
describe('MediaGridComponent', () => {
|
||||||
|
let component: MediaGridComponent;
|
||||||
|
let fixture: ComponentFixture<MediaGridComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ MediaGridComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(MediaGridComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { EntryService } from '../../../core/services/entry.service';
|
||||||
|
import { ConfigService } from '../../../core/services/config.service';
|
||||||
|
import { CustomMediaService } from '../../../core/services/custom-media.service';
|
||||||
|
import { Media } from '../../../shared/models/media.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-media-grid',
|
||||||
|
templateUrl: './media-grid.component.html',
|
||||||
|
styleUrls: ['./media-grid.component.css'],
|
||||||
|
})
|
||||||
|
export class MediaGridComponent implements OnInit {
|
||||||
|
@Input() mediaToDisplay: Media[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private customMediaService: CustomMediaService,
|
||||||
|
private configService: ConfigService,
|
||||||
|
private entryService: EntryService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {}
|
||||||
|
|
||||||
|
getPath(type: string, media: Media) {
|
||||||
|
let category = 'entries';
|
||||||
|
if (media.mediaable == 'collection') category = 'collections';
|
||||||
|
|
||||||
|
return `${this.configService.getBackendApiUrl()}/media/${category}/${type}/preview/${
|
||||||
|
media.path
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectMedia(media: any) {
|
||||||
|
this.entryService.selectEntryMedia(media.entry.id, media.id).subscribe({
|
||||||
|
next: (result) => {
|
||||||
|
// TODO add confirm modal
|
||||||
|
this.mediaToDisplay.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) {
|
||||||
|
let category = 'entries';
|
||||||
|
if (media.mediaable == 'collection') category = 'collections';
|
||||||
|
|
||||||
|
const fullSizePath = `${this.configService.getBackendApiUrl()}/media/${category}/${
|
||||||
|
media.type
|
||||||
|
}s/original/${media.path}`;
|
||||||
|
window.open(fullSizePath, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteMedia(media: Media) {
|
||||||
|
this.entryService.deleteEntryMedia(media.entry.id, media.id).subscribe({
|
||||||
|
next: (result) => {
|
||||||
|
// TODO add confirm modal
|
||||||
|
// TODO propagate delete to parent
|
||||||
|
this.mediaToDisplay = this.mediaToDisplay.filter(
|
||||||
|
(m) => m.id != media.id
|
||||||
|
);
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,54 +53,3 @@
|
|||||||
.add-btn:hover {
|
.add-btn:hover {
|
||||||
color: var(--shz-blue-default);
|
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);
|
|
||||||
}
|
|
||||||
@@ -1,30 +1,37 @@
|
|||||||
<div class="row row-cols-1 row-cols-md-1 row-cols-lg-1 row-cols-xl-1">
|
<!--breadcrumb-->
|
||||||
<div class="col">
|
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
|
||||||
<h6 class="mb-0 text-uppercase">Custom Uploaded Media</h6>
|
<div class="breadcrumb-title pe-3">Library</div>
|
||||||
<hr>
|
<div class="ps-3">
|
||||||
|
<nav aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb mb-0 p-0">
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">Media</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--end breadcrumb-->
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<ul class="nav nav-pills mb-3" role="tablist">
|
<ul class="nav nav-pills mb-3" role="tablist">
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" data-bs-toggle="pill" href="#posters-content" role="tab" aria-selected="true">
|
<a class="nav-link cursor-pointer" [class.active]="tab == 'poster'" (click)="setTab('poster')">
|
||||||
<div class="d-flex align-items-center">
|
<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-icon"><i class="bi bi-file-image me-1 fs-6"></i></div>
|
||||||
<div class="tab-title">Posters</div>
|
<div class="tab-title">Posters</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-bs-toggle="pill" href="#backdrops-content" role="tab" aria-selected="false"
|
<a class="nav-link cursor-pointer" [class.active]="tab == 'backdrop'" (click)="setTab('backdrop')">
|
||||||
tabindex="-1">
|
|
||||||
<div class="d-flex align-items-center">
|
<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-icon"><i class="bi bi-card-image me-1 fs-6"></i></div>
|
||||||
<div class="tab-title">Backdrops</div>
|
<div class="tab-title">Backdrops</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-bs-toggle="pill" href="#logos-content" role="tab" aria-selected="false"
|
<a class="nav-link cursor-pointer" [class.active]="tab == 'logo'" (click)="setTab('logo')">
|
||||||
tabindex="-1">
|
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<div class="tab-icon"><i class="bi bi-alphabet-uppercase me-1 fs-6"></i>
|
<div class="tab-icon"><i class="bi bi-alphabet-uppercase me-1 fs-6"></i>
|
||||||
</div>
|
</div>
|
||||||
@@ -35,66 +42,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class=" tab-content" id="pills-tabContent">
|
<div class=" tab-content" id="pills-tabContent">
|
||||||
<div class="tab-pane fade active show" id="posters-content" role="tabpanel">
|
<div class="tab-pane fade active show" id="posters-content" role="tabpanel">
|
||||||
<div class="row row-cols-4 row-cols-md-6 g-4">
|
<app-media-grid [mediaToDisplay]="mediaToDisplay"></app-media-grid>
|
||||||
<div class="col" *ngFor="let media of filterMedia('poster')">
|
|
||||||
<div class="card image-hover-container">
|
|
||||||
<img [src]="getPath('posters' , media)" 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)" 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-5 g-4">
|
|
||||||
<div class="col" *ngFor="let media of filterMedia('logo')">
|
|
||||||
<div class="card image-hover-container">
|
|
||||||
<img [src]="getPath('logos', media)" 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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,89 +1,76 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CustomMediaService } from '../../../core/services/custom-media.service';
|
import { CustomMediaService } from '../../../core/services/custom-media.service';
|
||||||
import { Media } from '../../../shared/models/media.model';
|
import { Media } from '../../../shared/models/media.model';
|
||||||
import { EntryService } from '../../../core/services/entry.service';
|
import { ScrollService } from '../../../core/services/scroll.service';
|
||||||
import { ConfigService } from '../../../core/services/config.service';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-media-page',
|
selector: 'app-media-page',
|
||||||
templateUrl: './media-page.component.html',
|
templateUrl: './media-page.component.html',
|
||||||
styleUrls: ['./media-page.component.css'],
|
styleUrls: ['./media-page.component.css'],
|
||||||
})
|
})
|
||||||
export class MediaPageComponent implements OnInit {
|
export class MediaPageComponent implements OnInit, OnDestroy {
|
||||||
customMedia: Media[] = [];
|
media: Media[] = [];
|
||||||
|
mediaFiltered: Media[] = [];
|
||||||
|
mediaToDisplay: Media[] = [];
|
||||||
tab: string = 'poster';
|
tab: string = 'poster';
|
||||||
|
|
||||||
|
private scrollSubscription!: Subscription;
|
||||||
|
private mediaServiceSubscription!: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private customMediaService: CustomMediaService,
|
private customMediaService: CustomMediaService,
|
||||||
private configService: ConfigService,
|
private scrollService: ScrollService
|
||||||
private entryService: EntryService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.customMediaService.fetchCustomMedia().subscribe({
|
this.mediaServiceSubscription = this.customMediaService
|
||||||
|
.fetchCustomMedia()
|
||||||
|
.subscribe({
|
||||||
next: (result) => {
|
next: (result) => {
|
||||||
console.log(result);
|
this.media = result;
|
||||||
this.customMedia = result;
|
this.filterMedia();
|
||||||
console.log(result);
|
this.loadNext();
|
||||||
},
|
},
|
||||||
error: (error) => {},
|
error: (error) => {
|
||||||
|
console.log("Couldn't fetch media.");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.scrollSubscription = this.scrollService.scrollEnd$.subscribe(() => {
|
||||||
|
this.loadNext();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
filterMedia(type: string) {
|
ngOnDestroy(): void {
|
||||||
return this.customMedia.filter((media) => media.type == type);
|
// Unsubscribe to avoid memory leaks
|
||||||
|
if (this.scrollSubscription) {
|
||||||
|
this.scrollSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPath(type: string, media: Media) {
|
if (this.mediaServiceSubscription) {
|
||||||
let category = 'entries';
|
this.mediaServiceSubscription.unsubscribe();
|
||||||
if (media.mediaable == 'collection') category = 'collections';
|
}
|
||||||
|
|
||||||
return `${this.configService.getBackendApiUrl()}/media/${category}/${type}/preview/${
|
|
||||||
media.path
|
|
||||||
}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTab(tab: string) {
|
setTab(tab: string) {
|
||||||
this.tab = tab;
|
this.tab = tab;
|
||||||
|
this.filterMedia();
|
||||||
|
this.loadNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMedia(media: Media) {
|
filterMedia() {
|
||||||
this.entryService.deleteEntryMedia(media.entry.id, media.id).subscribe({
|
this.mediaToDisplay = [];
|
||||||
next: (result) => {
|
this.mediaFiltered = this.media.filter((media) => media.type == this.tab);
|
||||||
// TODO add confirm modal
|
|
||||||
this.customMedia = this.customMedia.filter((m) => m.id != media.id);
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectMedia(media: any) {
|
loadNext(): void {
|
||||||
this.entryService.selectEntryMedia(media.entry.id, media.id).subscribe({
|
const nextItems = this.mediaFiltered.slice(
|
||||||
next: (result) => {
|
this.mediaToDisplay.length,
|
||||||
this.customMedia.forEach((m) => {
|
Math.min(this.mediaToDisplay.length + 30, this.mediaFiltered.length)
|
||||||
if (m.type == media.type) {
|
);
|
||||||
m.isSelected = false;
|
if (nextItems.length > 0) {
|
||||||
|
this.mediaToDisplay = [...this.mediaToDisplay, ...nextItems];
|
||||||
}
|
}
|
||||||
if ((m.id = result.id)) {
|
|
||||||
m.isSelected = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
expandMedia(media: any) {
|
|
||||||
let category = 'entries';
|
|
||||||
if (media.mediaable == 'collection') category = 'collections';
|
|
||||||
|
|
||||||
const fullSizePath = `${this.configService.getBackendApiUrl()}/media/${category}/${
|
|
||||||
media.type
|
|
||||||
}s/original/${media.path}`;
|
|
||||||
window.open(fullSizePath, '_blank');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|||||||
|
|
||||||
import { MediaPageComponent } from './media-page/media-page.component';
|
import { MediaPageComponent } from './media-page/media-page.component';
|
||||||
import { MediaRoutingModule } from './media-routing.module';
|
import { MediaRoutingModule } from './media-routing.module';
|
||||||
|
import { MediaGridComponent } from './media-grid/media-grid.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -17,7 +18,7 @@ import { MediaRoutingModule } from './media-routing.module';
|
|||||||
|
|
||||||
MediaRoutingModule,
|
MediaRoutingModule,
|
||||||
],
|
],
|
||||||
declarations: [MediaPageComponent],
|
declarations: [MediaPageComponent, MediaGridComponent],
|
||||||
exports: [],
|
exports: [],
|
||||||
})
|
})
|
||||||
export class MediaModule {}
|
export class MediaModule {}
|
||||||
Reference in new issue
Block a user