From 32a18cbf33a7cdbbe3d4885d32e4b67e19cdc1cf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Mar 2021 16:54:52 +0100 Subject: Add new plugin/peertube version notifs --- .../shared-main/users/user-notification.model.ts | 33 ++++++++++++++++++++++ .../users/user-notifications.component.html | 16 +++++++++++ .../users/user-notifications.component.ts | 6 ++-- 3 files changed, 53 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/users/user-notification.model.ts b/client/src/app/shared/shared-main/users/user-notification.model.ts index 1211995fd..88a4811da 100644 --- a/client/src/app/shared/shared-main/users/user-notification.model.ts +++ b/client/src/app/shared/shared-main/users/user-notification.model.ts @@ -6,6 +6,7 @@ import { AbuseState, ActorInfo, FollowState, + PluginType, UserNotification as UserNotificationServer, UserNotificationType, UserRight, @@ -74,20 +75,40 @@ export class UserNotification implements UserNotificationServer { } } + plugin?: { + name: string + type: PluginType + latestVersion: string + } + + peertube?: { + latestVersion: string + } + createdAt: string updatedAt: string // Additional fields videoUrl?: string commentUrl?: any[] + abuseUrl?: string abuseQueryParams?: { [id: string]: string } = {} + videoAutoBlacklistUrl?: string + accountUrl?: string + videoImportIdentifier?: string videoImportUrl?: string + instanceFollowUrl?: string + peertubeVersionLink?: string + + pluginUrl?: string + pluginQueryParams?: { [id: string]: string } = {} + constructor (hash: UserNotificationServer, user: AuthUser) { this.id = hash.id this.type = hash.type @@ -114,6 +135,9 @@ export class UserNotification implements UserNotificationServer { this.actorFollow = hash.actorFollow if (this.actorFollow) this.setAccountAvatarUrl(this.actorFollow.follower) + this.plugin = hash.plugin + this.peertube = hash.peertube + this.createdAt = hash.createdAt this.updatedAt = hash.updatedAt @@ -197,6 +221,15 @@ export class UserNotification implements UserNotificationServer { case UserNotificationType.AUTO_INSTANCE_FOLLOWING: this.instanceFollowUrl = '/admin/follows/following-list' break + + case UserNotificationType.NEW_PEERTUBE_VERSION: + this.peertubeVersionLink = 'https://joinpeertube.org/news' + break + + case UserNotificationType.NEW_PLUGIN_VERSION: + this.pluginUrl = `/admin/plugins/list-installed` + this.pluginQueryParams.pluginType = this.plugin.type + '' + break } } catch (err) { this.type = null diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.html b/client/src/app/shared/shared-main/users/user-notifications.component.html index 5e0e2f8e8..325f0eaae 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.html +++ b/client/src/app/shared/shared-main/users/user-notifications.component.html @@ -191,6 +191,22 @@ + + + +
+ A new version of the plugin/theme {{ notification.plugin.name }} is available: {{ notification.plugin.latestVersion }} +
+
+ + + + +
+ A new version of PeerTube is available: {{ notification.peertube.latestVersion }} +
+
+ diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.ts b/client/src/app/shared/shared-main/users/user-notifications.component.ts index 2f6ed061a..d7c722355 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.ts +++ b/client/src/app/shared/shared-main/users/user-notifications.component.ts @@ -45,7 +45,7 @@ export class UserNotificationsComponent implements OnInit { } loadNotifications (reset?: boolean) { - this.userNotificationService.listMyNotifications({ + const options = { pagination: this.componentPagination, ignoreLoadingBar: this.ignoreLoadingBar, sort: { @@ -53,7 +53,9 @@ export class UserNotificationsComponent implements OnInit { // if we order by creation date, we want DESC. all other fields are ASC (like unread). order: this.sortField === 'createdAt' ? -1 : 1 } - }) + } + + this.userNotificationService.listMyNotifications(options) .subscribe( result => { this.notifications = reset ? result.data : this.notifications.concat(result.data) -- cgit v1.2.3