From dc2b2938c293bae271a27a6c823f66496998b4d3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 May 2021 09:31:33 +0200 Subject: Sort channels by -updatedAt --- .../app/shared/shared-main/account/account.model.ts | 6 ++++++ .../src/app/shared/shared-main/account/actor.model.ts | 2 -- .../shared-main/video-channel/video-channel.model.ts | 4 ++++ .../video-channel/video-channel.service.ts | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 11 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts index 6d9f0ee65..7b5611f35 100644 --- a/client/src/app/shared/shared-main/account/account.model.ts +++ b/client/src/app/shared/shared-main/account/account.model.ts @@ -4,8 +4,12 @@ import { Actor } from './actor.model' export class Account extends Actor implements ServerAccount { displayName: string description: string + + updatedAt: Date | string + nameWithHost: string nameWithHostForced: string + mutedByUser: boolean mutedByInstance: boolean mutedServerByUser: boolean @@ -30,6 +34,8 @@ export class Account extends Actor implements ServerAccount { this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) + if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) + this.mutedByUser = false this.mutedByInstance = false this.mutedServerByUser = false diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index 6ba0bb09e..2fccc472a 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts @@ -12,7 +12,6 @@ export abstract class Actor implements ServerActor { followersCount: number createdAt: Date | string - updatedAt: Date | string avatar: ActorImage @@ -55,7 +54,6 @@ export abstract class Actor implements ServerActor { this.followersCount = hash.followersCount if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString()) - if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) this.avatar = hash.avatar this.isLocal = Actor.IS_LOCAL(this.host) diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts index c40dd5311..a9dcf2fa2 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts @@ -16,6 +16,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { banner: ActorImage bannerUrl: string + updatedAt: Date | string + ownerAccount?: ServerAccount ownerBy?: string @@ -59,6 +61,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { this.videosCount = hash.videosCount + if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) + if (hash.viewsPerDay) { this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) })) } diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts index e65261763..a89f1065a 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts @@ -40,23 +40,24 @@ export class VideoChannelService { ) } - listAccountVideoChannels ( - account: Account, - componentPagination?: ComponentPaginationLight, - withStats = false, + listAccountVideoChannels (options: { + account: Account + componentPagination?: ComponentPaginationLight + withStats?: boolean + sort?: string search?: string - ): Observable> { + }): Observable> { + const { account, componentPagination, withStats = false, sort, search } = options + const pagination = componentPagination ? this.restService.componentPaginationToRestPagination(componentPagination) : { start: 0, count: 20 } let params = new HttpParams() - params = this.restService.addRestGetParams(params, pagination) + params = this.restService.addRestGetParams(params, pagination, sort) params = params.set('withStats', withStats + '') - if (search) { - params = params.set('search', search) - } + if (search) params = params.set('search', search) const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels' return this.authHttp.get>(url, { params }) -- cgit v1.2.3 From ff0497fee85db13e81c90224d75e491faea0d0e3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 May 2021 15:31:18 +0200 Subject: Fix button icon in admin plugins --- client/src/app/shared/shared-main/buttons/button.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/buttons/button.component.scss b/client/src/app/shared/shared-main/buttons/button.component.scss index 09b5f95d7..22b24c853 100644 --- a/client/src/app/shared/shared-main/buttons/button.component.scss +++ b/client/src/app/shared/shared-main/buttons/button.component.scss @@ -30,7 +30,7 @@ span[class$=-button] { .action-button { @include peertube-button-link; - @include button-with-icon(21px, 0, -1px); + @include button-with-icon(21px); } .orange-button { -- cgit v1.2.3 From ceb8f322118b24508abc6dd0bc6813a43610eff3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 May 2021 15:27:43 +0200 Subject: Fix live ending banner --- .../src/app/shared/shared-main/plugins/plugin-placeholder.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts b/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts index 93ba9fb9b..4d5381e8d 100644 --- a/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts +++ b/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts @@ -3,7 +3,8 @@ import { PluginElementPlaceholder } from '@shared/models' @Component({ selector: 'my-plugin-placeholder', - template: '
' + template: '
', + styles: [ 'div { height: 100%; }' ] }) export class PluginPlaceholderComponent { -- cgit v1.2.3 From 74654b2ee2d6b03f8bfbb9bd9ab5e8c2b2e63f1d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 27 May 2021 13:30:51 +0200 Subject: Fix from now pipe --- .../shared/shared-main/angular/from-now.pipe.ts | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/angular/from-now.pipe.ts b/client/src/app/shared/shared-main/angular/from-now.pipe.ts index 5e7832807..d62c1f88e 100644 --- a/client/src/app/shared/shared-main/angular/from-now.pipe.ts +++ b/client/src/app/shared/shared-main/angular/from-now.pipe.ts @@ -3,32 +3,37 @@ import { Pipe, PipeTransform } from '@angular/core' // Thanks: https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site @Pipe({ name: 'myFromNow' }) export class FromNowPipe implements PipeTransform { - transform (arg: number | Date | string) { const argDate = new Date(arg) const seconds = Math.floor((Date.now() - argDate.getTime()) / 1000) - let interval = Math.round(seconds / 31536000) + let interval = Math.floor(seconds / 31536000) if (interval > 1) return $localize`${interval} years ago` - if (interval === 1) return $localize`${interval} year ago` + if (interval === 1) return $localize`1 year ago` - interval = Math.round(seconds / 2592000) + interval = Math.floor(seconds / 2419200) + // 12 months = 360 days, but a year ~ 365 days + // Display "1 year ago" rather than "12 months ago" + if (interval >= 12) return $localize`1 year ago` if (interval > 1) return $localize`${interval} months ago` - if (interval === 1) return $localize`${interval} month ago` + if (interval === 1) return $localize`1 month ago` - interval = Math.round(seconds / 604800) + interval = Math.floor(seconds / 604800) + // 4 weeks ~ 28 days, but our month is 30 days + // Display "1 month ago" rather than "4 weeks ago" + if (interval >= 4) return $localize`1 month ago` if (interval > 1) return $localize`${interval} weeks ago` - if (interval === 1) return $localize`${interval} week ago` + if (interval === 1) return $localize`1 week ago` - interval = Math.round(seconds / 86400) + interval = Math.floor(seconds / 86400) if (interval > 1) return $localize`${interval} days ago` - if (interval === 1) return $localize`${interval} day ago` + if (interval === 1) return $localize`1 day ago` - interval = Math.round(seconds / 3600) + interval = Math.floor(seconds / 3600) if (interval > 1) return $localize`${interval} hours ago` - if (interval === 1) return $localize`${interval} hour ago` + if (interval === 1) return $localize`1 hour ago` - interval = Math.round(seconds / 60) + interval = Math.floor(seconds / 60) if (interval >= 1) return $localize`${interval} min ago` return $localize`just now` -- cgit v1.2.3 From 2539932e16129992a2c0889b4ff527c265a8e2c7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 27 May 2021 15:59:55 +0200 Subject: Instance homepage support (#4007) * Prepare homepage parsers * Add ability to update instance hompage * Add ability to set homepage as landing page * Add homepage preview in admin * Dynamically update left menu for homepage * Inject home content in homepage * Add videos list and channel miniature custom markup * Remove unused elements in markup service --- .../shared-main/custom-page/custom-page.service.ts | 38 ++++++++++++++++++++++ .../app/shared/shared-main/custom-page/index.ts | 1 + .../app/shared/shared-main/shared-main.module.ts | 5 ++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 client/src/app/shared/shared-main/custom-page/custom-page.service.ts create mode 100644 client/src/app/shared/shared-main/custom-page/index.ts (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/custom-page/custom-page.service.ts b/client/src/app/shared/shared-main/custom-page/custom-page.service.ts new file mode 100644 index 000000000..e5c2b3cd4 --- /dev/null +++ b/client/src/app/shared/shared-main/custom-page/custom-page.service.ts @@ -0,0 +1,38 @@ +import { of } from 'rxjs' +import { catchError, map } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { RestExtractor } from '@app/core' +import { CustomPage } from '@shared/models' +import { environment } from '../../../../environments/environment' + +@Injectable() +export class CustomPageService { + static BASE_INSTANCE_HOMEPAGE_URL = environment.apiUrl + '/api/v1/custom-pages/homepage/instance' + + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor + ) { } + + getInstanceHomepage () { + return this.authHttp.get(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL) + .pipe( + catchError(err => { + if (err.status === 404) { + return of({ content: '' }) + } + + this.restExtractor.handleError(err) + }) + ) + } + + updateInstanceHomepage (content: string) { + return this.authHttp.put(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL, { content }) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(err => this.restExtractor.handleError(err)) + ) + } +} diff --git a/client/src/app/shared/shared-main/custom-page/index.ts b/client/src/app/shared/shared-main/custom-page/index.ts new file mode 100644 index 000000000..7269ece95 --- /dev/null +++ b/client/src/app/shared/shared-main/custom-page/index.ts @@ -0,0 +1 @@ +export * from './custom-page.service' diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index 772198cb2..f9b6085cf 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts @@ -29,6 +29,7 @@ import { } from './angular' import { AUTH_INTERCEPTOR_PROVIDER } from './auth' import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' +import { CustomPageService } from './custom-page' import { DateToggleComponent } from './date' import { FeedComponent } from './feeds' import { LoaderComponent, SmallLoaderComponent } from './loaders' @@ -171,7 +172,9 @@ import { VideoChannelService } from './video-channel' VideoCaptionService, - VideoChannelService + VideoChannelService, + + CustomPageService ] }) export class SharedMainModule { } -- cgit v1.2.3