Add local videos homepage

This commit is contained in:
Chocobozzz 2024-12-18 15:35:05 +01:00
parent efc013bead
commit 54aad475b0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 17 additions and 15 deletions

View File

@ -165,7 +165,8 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
links = links.concat([
{ label: $localize`Discover`, path: '/videos/overview' },
{ label: $localize`Browse videos`, path: '/videos/browse' }
{ label: $localize`Browse all videos`, path: '/videos/browse' },
{ label: $localize`Browse local videos`, path: '/videos/browse?scope=local' }
])
this.defaultLandingPageOptions = links.map(o => ({

View File

@ -67,7 +67,11 @@ export class RedirectService {
}
getDefaultRoute () {
return this.defaultRoute
return this.defaultRoute.split('?')[0]
}
getDefaultRouteQuery () {
return this.router.parseUrl(this.defaultRoute).queryParams
}
getDefaultTrendingSort () {

View File

@ -138,11 +138,11 @@ export class HeaderComponent implements OnInit, OnDestroy {
// ---------------------------------------------------------------------------
getDefaultRoute () {
return this.redirectService.getDefaultRoute().split('?')[0]
return this.redirectService.getDefaultRoute()
}
getDefaultRouteQuery () {
return this.router.parseUrl(this.redirectService.getDefaultRoute()).queryParams
return this.redirectService.getDefaultRouteQuery()
}
// ---------------------------------------------------------------------------

View File

@ -54,13 +54,13 @@
<ul class="ul-unstyle">
<li *ngFor="let link of menuSection.links">
@if (link.isPrimaryButton === true) {
<my-button class="d-block menu-button" [ngClass]="link.ngClass" theme="primary" [icon]="link.icon" [title]="link.label" [ptRouterLink]="link.path">
<my-button class="d-block menu-button" [ngClass]="link.ngClass" theme="primary" [icon]="link.icon" [title]="link.label" [ptRouterLink]="link.path" [ptQueryParams]="link.query">
@if (!collapsed) {
{{ link.label }}
}
</my-button>
} @else {
<a class="menu-link ellipsis" [routerLink]="link.path" routerLinkActive="active" [ngClass]="link.ngClass" [title]="link.label">
<a class="menu-link ellipsis" [routerLink]="link.path" [queryParams]="link.query" routerLinkActive="active" [ngClass]="link.ngClass" [title]="link.label">
<my-global-icon *ngIf="link.icon" [iconName]="link.icon" [ngClass]="link.iconClass" aria-hidden="true"></my-global-icon>
<span [ngClass]="{ 'visually-hidden': collapsed }">{{ link.label }}</span>
</a>

View File

@ -1,6 +1,6 @@
import { CommonModule } from '@angular/common'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { RouterLink, RouterLinkActive } from '@angular/router'
import { Params, RouterLink, RouterLinkActive } from '@angular/router'
import {
AuthService,
AuthStatus,
@ -14,7 +14,7 @@ import {
import { GlobalIconComponent, GlobalIconName } from '@app/shared/shared-icons/global-icon.component'
import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
import { ServerConfig, UserRight } from '@peertube/peertube-models'
import { UserRight } from '@peertube/peertube-models'
import debug from 'debug'
import { of, Subscription } from 'rxjs'
import { first, map, switchMap } from 'rxjs/operators'
@ -26,6 +26,7 @@ type MenuLink = {
label: string
path: string
query?: Params
isPrimaryButton?: boolean // default false
@ -61,8 +62,6 @@ export class MenuComponent implements OnInit, OnDestroy {
private user: AuthUser
private canSeeVideoMakerBlock: boolean
private serverConfig: ServerConfig
private authSub: Subscription
constructor (
@ -100,9 +99,6 @@ export class MenuComponent implements OnInit, OnDestroy {
this.onUserStateChange()
})
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
}
ngOnDestroy () {
@ -130,12 +126,13 @@ export class MenuComponent implements OnInit, OnDestroy {
}
private buildQuickLinks (): MenuSection {
const base = {
const base: MenuSection = {
key: 'quick-access',
title: $localize`Quick access`,
links: [
{
path: this.redirectService.getDefaultRoute(),
query: this.redirectService.getDefaultRouteQuery(),
icon: 'home' as GlobalIconName,
label: $localize`Home`
}

View File

@ -149,7 +149,7 @@ export class VideosListComponent implements OnInit, OnChanges, OnDestroy {
: []
this.filters = new VideoFilters(this.defaultSort, this.defaultScope, hiddenFilters)
this.filters.load({ ...this.route.snapshot.queryParams, scope: this.defaultScope })
this.filters.load({ scope: this.defaultScope, ...this.route.snapshot.queryParams })
this.groupedDateLabels = {
[GroupDate.UNKNOWN]: null,