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 --- ...y-account-notification-preferences.component.ts | 8 ++++-- .../shared-main/users/user-notification.model.ts | 33 ++++++++++++++++++++++ .../users/user-notifications.component.html | 16 +++++++++++ .../users/user-notifications.component.ts | 6 ++-- 4 files changed, 59 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts index ad7497f45..c7e173038 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts @@ -42,7 +42,9 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { newInstanceFollower: $localize`Your instance has a new follower`, autoInstanceFollowing: $localize`Your instance automatically followed another instance`, abuseNewMessage: $localize`An abuse report received a new message`, - abuseStateChange: $localize`One of your abuse reports has been accepted or rejected by moderators` + abuseStateChange: $localize`One of your abuse reports has been accepted or rejected by moderators`, + newPeerTubeVersion: $localize`A new PeerTube version is available`, + newPluginVersion: $localize`One of your plugin/theme has a new available version` } this.notificationSettingKeys = Object.keys(this.labelNotifications) as (keyof UserNotificationSetting)[] @@ -51,7 +53,9 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { videoAutoBlacklistAsModerator: UserRight.MANAGE_VIDEO_BLACKLIST, newUserRegistration: UserRight.MANAGE_USERS, newInstanceFollower: UserRight.MANAGE_SERVER_FOLLOW, - autoInstanceFollowing: UserRight.MANAGE_CONFIGURATION + autoInstanceFollowing: UserRight.MANAGE_CONFIGURATION, + newPeerTubeVersion: UserRight.MANAGE_DEBUG, + newPluginVersion: UserRight.MANAGE_DEBUG } } 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