diff options
Diffstat (limited to 'client/src/app/core')
17 files changed, 58 insertions, 44 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 226075265..a1e23bfbb 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -1,16 +1,16 @@ | |||
1 | import { Observable, of } from 'rxjs' | 1 | import { Observable, of } from 'rxjs' |
2 | import { map } from 'rxjs/operators' | 2 | import { map } from 'rxjs/operators' |
3 | import { User } from '@app/core/users/user.model' | 3 | import { User } from '@app/core/users/user.model' |
4 | import { OAuthUserTokens } from '@root-helpers/users' | 4 | import { hasUserRight } from '@peertube/peertube-core-utils' |
5 | import { hasUserRight } from '@shared/core-utils/users' | ||
6 | import { | 5 | import { |
7 | MyUser as ServerMyUserModel, | 6 | MyUser as ServerMyUserModel, |
8 | MyUserSpecialPlaylist, | 7 | MyUserSpecialPlaylist, |
9 | User as ServerUserModel, | 8 | User as ServerUserModel, |
10 | UserRight, | 9 | UserRightType, |
11 | UserRole, | 10 | UserRole, |
12 | UserVideoQuota | 11 | UserVideoQuota |
13 | } from '@shared/models' | 12 | } from '@peertube/peertube-models' |
13 | import { OAuthUserTokens } from '@root-helpers/users' | ||
14 | 14 | ||
15 | export class AuthUser extends User implements ServerMyUserModel { | 15 | export class AuthUser extends User implements ServerMyUserModel { |
16 | oauthTokens: OAuthUserTokens | 16 | oauthTokens: OAuthUserTokens |
@@ -42,7 +42,7 @@ export class AuthUser extends User implements ServerMyUserModel { | |||
42 | this.oauthTokens.refreshToken = refreshToken | 42 | this.oauthTokens.refreshToken = refreshToken |
43 | } | 43 | } |
44 | 44 | ||
45 | hasRight (right: UserRight) { | 45 | hasRight (right: UserRightType) { |
46 | return hasUserRight(this.role.id, right) | 46 | return hasUserRight(this.role.id, right) |
47 | } | 47 | } |
48 | 48 | ||
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 6fe601d8d..bc67ab7a0 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -6,7 +6,7 @@ import { Injectable } from '@angular/core' | |||
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { Notifier } from '@app/core/notification/notifier.service' | 7 | import { Notifier } from '@app/core/notification/notifier.service' |
8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' | 8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' |
9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@peertube/peertube-models' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
12 | import { RedirectService } from '../routing' | 12 | import { RedirectService } from '../routing' |
diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index d865c7da2..39e89f6e3 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts | |||
@@ -2,7 +2,7 @@ import { fromEvent } from 'rxjs' | |||
2 | import { debounceTime } from 'rxjs/operators' | 2 | import { debounceTime } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { GlobalIconName } from '@app/shared/shared-icons' | 4 | import { GlobalIconName } from '@app/shared/shared-icons' |
5 | import { HTMLServerConfig } from '@shared/models/server' | 5 | import { HTMLServerConfig } from '@peertube/peertube-models' |
6 | import { ScreenService } from '../wrappers' | 6 | import { ScreenService } from '../wrappers' |
7 | 7 | ||
8 | export type MenuLink = { | 8 | export type MenuLink = { |
diff --git a/client/src/app/core/notification/peertube-socket.service.ts b/client/src/app/core/notification/peertube-socket.service.ts index 50a11e948..15af9a310 100644 --- a/client/src/app/core/notification/peertube-socket.service.ts +++ b/client/src/app/core/notification/peertube-socket.service.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Subject } from 'rxjs' | 1 | import { Subject } from 'rxjs' |
2 | import { ManagerOptions, Socket, SocketOptions } from 'socket.io-client' | 2 | import { ManagerOptions, Socket, SocketOptions } from 'socket.io-client' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@shared/models' | 4 | import { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@peertube/peertube-models' |
5 | import { environment } from '../../../environments/environment' | 5 | import { environment } from '../../../environments/environment' |
6 | import { AuthService } from '../auth' | 6 | import { AuthService } from '../auth' |
7 | 7 | ||
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index d9fef8389..59c627c05 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts | |||
@@ -3,7 +3,7 @@ import { mergeMap, switchMap } from 'rxjs/operators' | |||
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { PluginService } from '@app/core/plugins/plugin.service' | 4 | import { PluginService } from '@app/core/plugins/plugin.service' |
5 | import { logger } from '@root-helpers/logger' | 5 | import { logger } from '@root-helpers/logger' |
6 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' | 6 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@peertube/peertube-models' |
7 | import { AuthService, AuthStatus } from '../auth' | 7 | import { AuthService, AuthStatus } from '../auth' |
8 | 8 | ||
9 | type RawFunction<U, T> = (params: U) => T | 9 | type RawFunction<U, T> = (params: U) => T |
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index bd8c61d9a..d37b2e5f7 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -10,22 +10,22 @@ import { RestExtractor } from '@app/core/rest' | |||
10 | import { ServerService } from '@app/core/server/server.service' | 10 | import { ServerService } from '@app/core/server/server.service' |
11 | import { getDevLocale, isOnDevLocale } from '@app/helpers' | 11 | import { getDevLocale, isOnDevLocale } from '@app/helpers' |
12 | import { CustomModalComponent } from '@app/modal/custom-modal.component' | 12 | import { CustomModalComponent } from '@app/modal/custom-modal.component' |
13 | import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' | 13 | import { getCompleteLocale, getKeys, isDefaultLocale, peertubeTranslate } from '@peertube/peertube-core-utils' |
14 | import { getKeys } from '@shared/core-utils' | ||
15 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' | ||
16 | import { | 14 | import { |
17 | ClientHook, | 15 | ClientHook, |
18 | ClientHookName, | 16 | ClientHookName, |
19 | PluginClientScope, | 17 | PluginClientScope, |
20 | PluginTranslation, | 18 | PluginTranslation, |
21 | PluginType, | 19 | PluginType, |
20 | PluginType_Type, | ||
22 | PublicServerSetting, | 21 | PublicServerSetting, |
23 | RegisterClientFormFieldOptions, | 22 | RegisterClientFormFieldOptions, |
24 | RegisterClientRouteOptions, | 23 | RegisterClientRouteOptions, |
25 | RegisterClientSettingsScriptOptions, | 24 | RegisterClientSettingsScriptOptions, |
26 | RegisterClientVideoFieldOptions, | 25 | RegisterClientVideoFieldOptions, |
27 | ServerConfigPlugin | 26 | ServerConfigPlugin |
28 | } from '@shared/models' | 27 | } from '@peertube/peertube-models' |
28 | import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' | ||
29 | import { environment } from '../../../environments/environment' | 29 | import { environment } from '../../../environments/environment' |
30 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' | 30 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' |
31 | 31 | ||
@@ -110,7 +110,7 @@ export class PluginService implements ClientHook { | |||
110 | return this.pluginsManager.removePlugin(plugin) | 110 | return this.pluginsManager.removePlugin(plugin) |
111 | } | 111 | } |
112 | 112 | ||
113 | nameToNpmName (name: string, type: PluginType) { | 113 | nameToNpmName (name: string, type: PluginType_Type) { |
114 | const prefix = type === PluginType.PLUGIN | 114 | const prefix = type === PluginType.PLUGIN |
115 | ? 'peertube-plugin-' | 115 | ? 'peertube-plugin-' |
116 | : 'peertube-theme-' | 116 | : 'peertube-theme-' |
diff --git a/client/src/app/core/renderer/html-renderer.service.ts b/client/src/app/core/renderer/html-renderer.service.ts index 7776ccad5..37741c079 100644 --- a/client/src/app/core/renderer/html-renderer.service.ts +++ b/client/src/app/core/renderer/html-renderer.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { getCustomMarkupSanitizeOptions, getDefaultSanitizeOptions } from '@shared/core-utils/renderer/html' | 2 | import { getCustomMarkupSanitizeOptions, getDefaultSanitizeOptions } from '@peertube/peertube-core-utils' |
3 | import { LinkifierService } from './linkifier.service' | 3 | import { LinkifierService } from './linkifier.service' |
4 | 4 | ||
5 | @Injectable() | 5 | @Injectable() |
diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts index ec3b683bb..907b92232 100644 --- a/client/src/app/core/renderer/markdown.service.ts +++ b/client/src/app/core/renderer/markdown.service.ts | |||
@@ -1,13 +1,14 @@ | |||
1 | import * as MarkdownIt from 'markdown-it' | 1 | import * as MarkdownIt from 'markdown-it' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' | ||
4 | import { | 3 | import { |
4 | buildVideoLink, | ||
5 | COMPLETE_RULES, | 5 | COMPLETE_RULES, |
6 | decorateVideoLink, | ||
6 | ENHANCED_RULES, | 7 | ENHANCED_RULES, |
7 | ENHANCED_WITH_HTML_RULES, | 8 | ENHANCED_WITH_HTML_RULES, |
8 | TEXT_RULES, | 9 | TEXT_RULES, |
9 | TEXT_WITH_HTML_RULES | 10 | TEXT_WITH_HTML_RULES |
10 | } from '@shared/core-utils/renderer/markdown' | 11 | } from '@peertube/peertube-core-utils' |
11 | import { HtmlRendererService } from './html-renderer.service' | 12 | import { HtmlRendererService } from './html-renderer.service' |
12 | 13 | ||
13 | type MarkdownParsers = { | 14 | type MarkdownParsers = { |
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index c6c1e183f..bcc50c0f4 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { throwError as observableThrowError } from 'rxjs' | 1 | import { throwError as observableThrowError } from 'rxjs' |
2 | import { HttpHeaderResponse } from '@angular/common/http' | ||
2 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 3 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
3 | import { Router } from '@angular/router' | 4 | import { Router } from '@angular/router' |
4 | import { DateFormat, dateToHuman } from '@app/helpers' | 5 | import { DateFormat, dateToHuman } from '@app/helpers' |
6 | import { HttpStatusCode, HttpStatusCodeType, ResultList } from '@peertube/peertube-models' | ||
5 | import { logger } from '@root-helpers/logger' | 7 | import { logger } from '@root-helpers/logger' |
6 | import { HttpStatusCode, ResultList } from '@shared/models' | ||
7 | import { HttpHeaderResponse } from '@angular/common/http' | ||
8 | 8 | ||
9 | @Injectable() | 9 | @Injectable() |
10 | export class RestExtractor { | 10 | export class RestExtractor { |
@@ -45,7 +45,11 @@ export class RestExtractor { | |||
45 | return target | 45 | return target |
46 | } | 46 | } |
47 | 47 | ||
48 | redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { | 48 | redirectTo404IfNotFound ( |
49 | obj: { status: HttpStatusCodeType }, | ||
50 | type: 'video' | 'other', | ||
51 | status: HttpStatusCodeType[] = [ HttpStatusCode.NOT_FOUND_404 ] | ||
52 | ) { | ||
49 | if (obj?.status && status.includes(obj.status)) { | 53 | if (obj?.status && status.includes(obj.status)) { |
50 | // Do not use redirectService to avoid circular dependencies | 54 | // Do not use redirectService to avoid circular dependencies |
51 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) | 55 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) |
diff --git a/client/src/app/core/routing/homepage-redirect.component.ts b/client/src/app/core/routing/homepage-redirect.component.ts index 9e3848038..e9be832e0 100644 --- a/client/src/app/core/routing/homepage-redirect.component.ts +++ b/client/src/app/core/routing/homepage-redirect.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute } from '@angular/router' | 2 | import { ActivatedRoute } from '@angular/router' |
3 | import { is18nPath } from '@shared/core-utils/i18n/i18n' | 3 | import { is18nPath } from '@peertube/peertube-core-utils' |
4 | import { RedirectService } from './redirect.service' | 4 | import { RedirectService } from './redirect.service' |
5 | 5 | ||
6 | /* | 6 | /* |
diff --git a/client/src/app/core/routing/meta.service.ts b/client/src/app/core/routing/meta.service.ts index 97e440faf..d50f0d65a 100644 --- a/client/src/app/core/routing/meta.service.ts +++ b/client/src/app/core/routing/meta.service.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Meta, Title } from '@angular/platform-browser' | 2 | import { Meta, Title } from '@angular/platform-browser' |
3 | import { HTMLServerConfig } from '@shared/models/server' | 3 | import { HTMLServerConfig } from '@peertube/peertube-models' |
4 | import { ServerService } from '../server' | 4 | import { ServerService } from '../server' |
5 | 5 | ||
6 | export interface MetaSettings { | 6 | export interface MetaSettings { |
diff --git a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts index 038e5031c..f7d192feb 100644 --- a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts +++ b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | 4 | import { ScopedToken } from '@peertube/peertube-models' |
5 | import { environment } from '../../../environments/environment' | 5 | import { environment } from '../../../environments/environment' |
6 | import { RestExtractor } from '../rest' | 6 | import { RestExtractor } from '../rest' |
7 | 7 | ||
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 41cb4791a..75ac8ddc1 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -3,9 +3,16 @@ import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' | |||
3 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient } from '@angular/common/http' |
4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
5 | import { getDevLocale, isOnDevLocale } from '@app/helpers' | 5 | import { getDevLocale, isOnDevLocale } from '@app/helpers' |
6 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@peertube/peertube-core-utils' | ||
7 | import { | ||
8 | HTMLServerConfig, | ||
9 | ServerConfig, | ||
10 | ServerStats, | ||
11 | VideoConstant, | ||
12 | VideoPlaylistPrivacyType, | ||
13 | VideoPrivacyType | ||
14 | } from '@peertube/peertube-models' | ||
6 | import { logger } from '@root-helpers/logger' | 15 | import { logger } from '@root-helpers/logger' |
7 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' | ||
8 | import { HTMLServerConfig, ServerConfig, ServerStats, VideoConstant } from '@shared/models' | ||
9 | import { environment } from '../../../environments/environment' | 16 | import { environment } from '../../../environments/environment' |
10 | 17 | ||
11 | @Injectable() | 18 | @Injectable() |
@@ -21,8 +28,8 @@ export class ServerService { | |||
21 | private localeObservable: Observable<any> | 28 | private localeObservable: Observable<any> |
22 | private videoLicensesObservable: Observable<VideoConstant<number>[]> | 29 | private videoLicensesObservable: Observable<VideoConstant<number>[]> |
23 | private videoCategoriesObservable: Observable<VideoConstant<number>[]> | 30 | private videoCategoriesObservable: Observable<VideoConstant<number>[]> |
24 | private videoPrivaciesObservable: Observable<VideoConstant<number>[]> | 31 | private videoPrivaciesObservable: Observable<VideoConstant<VideoPrivacyType>[]> |
25 | private videoPlaylistPrivaciesObservable: Observable<VideoConstant<number>[]> | 32 | private videoPlaylistPrivaciesObservable: Observable<VideoConstant<VideoPlaylistPrivacyType>[]> |
26 | private videoLanguagesObservable: Observable<VideoConstant<string>[]> | 33 | private videoLanguagesObservable: Observable<VideoConstant<string>[]> |
27 | private configObservable: Observable<ServerConfig> | 34 | private configObservable: Observable<ServerConfig> |
28 | 35 | ||
@@ -123,7 +130,7 @@ export class ServerService { | |||
123 | 130 | ||
124 | getVideoPrivacies () { | 131 | getVideoPrivacies () { |
125 | if (!this.videoPrivaciesObservable) { | 132 | if (!this.videoPrivaciesObservable) { |
126 | this.videoPrivaciesObservable = this.loadAttributeEnum<number>(ServerService.BASE_VIDEO_URL, 'privacies') | 133 | this.videoPrivaciesObservable = this.loadAttributeEnum<VideoPrivacyType>(ServerService.BASE_VIDEO_URL, 'privacies') |
127 | } | 134 | } |
128 | 135 | ||
129 | return this.videoPrivaciesObservable.pipe(first()) | 136 | return this.videoPrivaciesObservable.pipe(first()) |
@@ -131,7 +138,10 @@ export class ServerService { | |||
131 | 138 | ||
132 | getVideoPlaylistPrivacies () { | 139 | getVideoPlaylistPrivacies () { |
133 | if (!this.videoPlaylistPrivaciesObservable) { | 140 | if (!this.videoPlaylistPrivaciesObservable) { |
134 | this.videoPlaylistPrivaciesObservable = this.loadAttributeEnum<number>(ServerService.BASE_VIDEO_PLAYLIST_URL, 'privacies') | 141 | this.videoPlaylistPrivaciesObservable = this.loadAttributeEnum<VideoPlaylistPrivacyType>( |
142 | ServerService.BASE_VIDEO_PLAYLIST_URL, | ||
143 | 'privacies' | ||
144 | ) | ||
135 | } | 145 | } |
136 | 146 | ||
137 | return this.videoPlaylistPrivaciesObservable.pipe(first()) | 147 | return this.videoPlaylistPrivaciesObservable.pipe(first()) |
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index ead1770ba..22eb5ddd3 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' | |||
2 | import { logger } from '@root-helpers/logger' | 2 | import { logger } from '@root-helpers/logger' |
3 | import { capitalizeFirstLetter } from '@root-helpers/string' | 3 | import { capitalizeFirstLetter } from '@root-helpers/string' |
4 | import { UserLocalStorageKeys } from '@root-helpers/users' | 4 | import { UserLocalStorageKeys } from '@root-helpers/users' |
5 | import { HTMLServerConfig, ServerConfigTheme } from '@shared/models' | 5 | import { HTMLServerConfig, ServerConfigTheme } from '@peertube/peertube-models' |
6 | import { environment } from '../../../environments/environment' | 6 | import { environment } from '../../../environments/environment' |
7 | import { AuthService } from '../auth' | 7 | import { AuthService } from '../auth' |
8 | import { PluginService } from '../plugins/plugin.service' | 8 | import { PluginService } from '../plugins/plugin.service' |
diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts index a87f3b98a..431a57343 100644 --- a/client/src/app/core/users/user-local-storage.service.ts +++ b/client/src/app/core/users/user-local-storage.service.ts | |||
@@ -1,13 +1,11 @@ | |||
1 | |||
2 | import { filter, throttleTime } from 'rxjs' | 1 | import { filter, throttleTime } from 'rxjs' |
3 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
4 | import { AuthService, AuthStatus } from '@app/core/auth' | 3 | import { AuthService, AuthStatus } from '@app/core/auth' |
4 | import { objectKeysTyped } from '@peertube/peertube-core-utils' | ||
5 | import { NSFWPolicyType, UserRoleType, UserUpdateMe } from '@peertube/peertube-models' | ||
5 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' | 6 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' |
6 | import { logger } from '@root-helpers/logger' | 7 | import { logger } from '@root-helpers/logger' |
7 | import { OAuthUserTokens, UserLocalStorageKeys } from '@root-helpers/users' | 8 | import { OAuthUserTokens, UserLocalStorageKeys } from '@root-helpers/users' |
8 | import { objectKeysTyped } from '@shared/core-utils' | ||
9 | import { UserRole, UserUpdateMe } from '@shared/models' | ||
10 | import { NSFWPolicyType } from '@shared/models/videos' | ||
11 | import { ServerService } from '../server' | 9 | import { ServerService } from '../server' |
12 | import { LocalStorageService } from '../wrappers/storage.service' | 10 | import { LocalStorageService } from '../wrappers/storage.service' |
13 | 11 | ||
@@ -61,7 +59,7 @@ export class UserLocalStorageService { | |||
61 | username: this.localStorageService.getItem(UserLocalStorageKeys.USERNAME), | 59 | username: this.localStorageService.getItem(UserLocalStorageKeys.USERNAME), |
62 | email: this.localStorageService.getItem(UserLocalStorageKeys.EMAIL), | 60 | email: this.localStorageService.getItem(UserLocalStorageKeys.EMAIL), |
63 | role: { | 61 | role: { |
64 | id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRole, | 62 | id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRoleType, |
65 | label: '' | 63 | label: '' |
66 | }, | 64 | }, |
67 | 65 | ||
@@ -74,7 +72,7 @@ export class UserLocalStorageService { | |||
74 | username: string | 72 | username: string |
75 | email: string | 73 | email: string |
76 | role: { | 74 | role: { |
77 | id: UserRole | 75 | id: UserRoleType |
78 | } | 76 | } |
79 | }) { | 77 | }) { |
80 | this.localStorageService.setItem(UserLocalStorageKeys.ID, user.id.toString()) | 78 | this.localStorageService.setItem(UserLocalStorageKeys.ID, user.id.toString()) |
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 54b749a4c..ffc7c2b44 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts | |||
@@ -1,17 +1,18 @@ | |||
1 | import { Account } from '@app/shared/shared-main/account/account.model' | 1 | import { Account } from '@app/shared/shared-main/account/account.model' |
2 | import { objectKeysTyped } from '@shared/core-utils' | 2 | import { hasUserRight, objectKeysTyped } from '@peertube/peertube-core-utils' |
3 | import { hasUserRight } from '@shared/core-utils/users' | ||
4 | import { | 3 | import { |
5 | ActorImage, | 4 | ActorImage, |
6 | HTMLServerConfig, | 5 | HTMLServerConfig, |
7 | NSFWPolicyType, | 6 | NSFWPolicyType, |
8 | User as UserServerModel, | 7 | User as UserServerModel, |
9 | UserAdminFlag, | 8 | UserAdminFlag, |
9 | UserAdminFlagType, | ||
10 | UserNotificationSetting, | 10 | UserNotificationSetting, |
11 | UserRight, | 11 | UserRightType, |
12 | UserRole, | 12 | UserRole, |
13 | UserRoleType, | ||
13 | VideoChannel | 14 | VideoChannel |
14 | } from '@shared/models' | 15 | } from '@peertube/peertube-models' |
15 | 16 | ||
16 | export class User implements UserServerModel { | 17 | export class User implements UserServerModel { |
17 | id: number | 18 | id: number |
@@ -23,7 +24,7 @@ export class User implements UserServerModel { | |||
23 | emailPublic: boolean | 24 | emailPublic: boolean |
24 | nsfwPolicy: NSFWPolicyType | 25 | nsfwPolicy: NSFWPolicyType |
25 | 26 | ||
26 | adminFlags?: UserAdminFlag | 27 | adminFlags?: UserAdminFlagType |
27 | 28 | ||
28 | autoPlayVideo: boolean | 29 | autoPlayVideo: boolean |
29 | autoPlayNextVideo: boolean | 30 | autoPlayNextVideo: boolean |
@@ -35,7 +36,7 @@ export class User implements UserServerModel { | |||
35 | videoLanguages: string[] | 36 | videoLanguages: string[] |
36 | 37 | ||
37 | role: { | 38 | role: { |
38 | id: UserRole | 39 | id: UserRoleType |
39 | label: string | 40 | label: string |
40 | } | 41 | } |
41 | 42 | ||
@@ -124,7 +125,7 @@ export class User implements UserServerModel { | |||
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | hasRight (right: UserRight) { | 128 | hasRight (right: UserRightType) { |
128 | return hasUserRight(this.role.id, right) | 129 | return hasUserRight(this.role.id, right) |
129 | } | 130 | } |
130 | 131 | ||
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts index b4024c02d..7ad0ee9bf 100644 --- a/client/src/app/core/users/user.service.ts +++ b/client/src/app/core/users/user.service.ts | |||
@@ -3,7 +3,7 @@ import { catchError, first, map, shareReplay } from 'rxjs/operators' | |||
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { AuthService } from '@app/core/auth' | 5 | import { AuthService } from '@app/core/auth' |
6 | import { ActorImage, User as UserServerModel, UserUpdateMe, UserVideoQuota } from '@shared/models' | 6 | import { ActorImage, User as UserServerModel, UserUpdateMe, UserVideoQuota } from '@peertube/peertube-models' |
7 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
8 | import { RestExtractor } from '../rest' | 8 | import { RestExtractor } from '../rest' |
9 | import { UserLocalStorageService } from './user-local-storage.service' | 9 | import { UserLocalStorageService } from './user-local-storage.service' |