diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-18 14:35:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-18 14:35:31 +0200 |
commit | c199c427d4ae586339822320f20f512a7a19dc3f (patch) | |
tree | 9cbe8bebc25e97d2e8086c41bcd7180dd752dbac /client/src/app/shared | |
parent | cdf4cb9eaf5f6bc71f7c1e1963c07575f1d2593d (diff) | |
download | PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.tar.gz PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.tar.zst PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.zip |
Better typings
Diffstat (limited to 'client/src/app/shared')
19 files changed, 48 insertions, 37 deletions
diff --git a/client/src/app/shared/buttons/action-dropdown.component.ts b/client/src/app/shared/buttons/action-dropdown.component.ts index 9877f639d..d8026ef41 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.ts +++ b/client/src/app/shared/buttons/action-dropdown.component.ts | |||
@@ -2,9 +2,9 @@ import { Component, Input } from '@angular/core' | |||
2 | 2 | ||
3 | export type DropdownAction<T> = { | 3 | export type DropdownAction<T> = { |
4 | label?: string | 4 | label?: string |
5 | handler?: (T: any) => any | 5 | handler?: (a: T) => any |
6 | linkBuilder?: (T: any) => (string | number)[] | 6 | linkBuilder?: (a: T) => (string | number)[] |
7 | isDisplayed?: (T: any) => boolean | 7 | isDisplayed?: (a: T) => boolean |
8 | } | 8 | } |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
diff --git a/client/src/app/shared/buttons/button.component.ts b/client/src/app/shared/buttons/button.component.ts index cccf98bc3..1a1162f09 100644 --- a/client/src/app/shared/buttons/button.component.ts +++ b/client/src/app/shared/buttons/button.component.ts | |||
@@ -8,9 +8,9 @@ import { Component, Input } from '@angular/core' | |||
8 | 8 | ||
9 | export class ButtonComponent { | 9 | export class ButtonComponent { |
10 | @Input() label = '' | 10 | @Input() label = '' |
11 | @Input() className: any = undefined | 11 | @Input() className: string = undefined |
12 | @Input() icon: any = undefined | 12 | @Input() icon: string = undefined |
13 | @Input() title: any = undefined | 13 | @Input() title: string = undefined |
14 | 14 | ||
15 | getTitle () { | 15 | getTitle () { |
16 | return this.title || this.label | 16 | return this.title || this.label |
diff --git a/client/src/app/shared/buttons/edit-button.component.ts b/client/src/app/shared/buttons/edit-button.component.ts index ea552663a..1fe4f7b30 100644 --- a/client/src/app/shared/buttons/edit-button.component.ts +++ b/client/src/app/shared/buttons/edit-button.component.ts | |||
@@ -8,5 +8,5 @@ import { Component, Input } from '@angular/core' | |||
8 | 8 | ||
9 | export class EditButtonComponent { | 9 | export class EditButtonComponent { |
10 | @Input() label: string | 10 | @Input() label: string |
11 | @Input() routerLink: any = [] | 11 | @Input() routerLink: string[] = [] |
12 | } | 12 | } |
diff --git a/client/src/app/shared/guards/can-deactivate-guard.service.ts b/client/src/app/shared/guards/can-deactivate-guard.service.ts index e2a79e8c4..3a35fcfb3 100644 --- a/client/src/app/shared/guards/can-deactivate-guard.service.ts +++ b/client/src/app/shared/guards/can-deactivate-guard.service.ts | |||
@@ -4,8 +4,10 @@ import { Observable } from 'rxjs' | |||
4 | import { ConfirmService } from '../../core/index' | 4 | import { ConfirmService } from '../../core/index' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | 5 | import { I18n } from '@ngx-translate/i18n-polyfill' |
6 | 6 | ||
7 | export type CanComponentDeactivateResult = { text?: string, canDeactivate: Observable<boolean> | boolean } | ||
8 | |||
7 | export interface CanComponentDeactivate { | 9 | export interface CanComponentDeactivate { |
8 | canDeactivate: () => { text?: string, canDeactivate: Observable<boolean> | boolean } | 10 | canDeactivate: () => CanComponentDeactivateResult |
9 | } | 11 | } |
10 | 12 | ||
11 | @Injectable() | 13 | @Injectable() |
diff --git a/client/src/app/shared/misc/help.component.ts b/client/src/app/shared/misc/help.component.ts index ccce1ccfa..ba0452e77 100644 --- a/client/src/app/shared/misc/help.component.ts +++ b/client/src/app/shared/misc/help.component.ts | |||
@@ -60,7 +60,7 @@ export class HelpComponent implements OnInit, OnChanges { | |||
60 | } | 60 | } |
61 | 61 | ||
62 | private createMarkdownList (rules: string[]) { | 62 | private createMarkdownList (rules: string[]) { |
63 | const rulesToText: any = { | 63 | const rulesToText = { |
64 | 'emphasis': this.i18n('Emphasis'), | 64 | 'emphasis': this.i18n('Emphasis'), |
65 | 'link': this.i18n('Links'), | 65 | 'link': this.i18n('Links'), |
66 | 'newline': this.i18n('New lines'), | 66 | 'newline': this.i18n('New lines'), |
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 934f6c618..f149569ef 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts | |||
@@ -33,7 +33,7 @@ export class RestExtractor { | |||
33 | return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) | 33 | return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) |
34 | } | 34 | } |
35 | 35 | ||
36 | convertDateToHuman (target: any, fieldsToConvert: string[]) { | 36 | convertDateToHuman (target: { [ id: string ]: string }, fieldsToConvert: string[]) { |
37 | fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) | 37 | fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) |
38 | 38 | ||
39 | return target | 39 | return target |
@@ -83,7 +83,7 @@ export class RestExtractor { | |||
83 | errorMessage = err | 83 | errorMessage = err |
84 | } | 84 | } |
85 | 85 | ||
86 | const errorObj: any = { | 86 | const errorObj: { message: string, status: string, body: string } = { |
87 | message: errorMessage, | 87 | message: errorMessage, |
88 | status: undefined, | 88 | status: undefined, |
89 | body: undefined | 89 | body: undefined |
diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts index 41824a18f..e6d4e6e5e 100644 --- a/client/src/app/shared/rest/rest.service.ts +++ b/client/src/app/shared/rest/rest.service.ts | |||
@@ -32,7 +32,7 @@ export class RestService { | |||
32 | return newParams | 32 | return newParams |
33 | } | 33 | } |
34 | 34 | ||
35 | addObjectParams (params: HttpParams, object: any) { | 35 | addObjectParams (params: HttpParams, object: { [ name: string ]: any }) { |
36 | for (const name of Object.keys(object)) { | 36 | for (const name of Object.keys(object)) { |
37 | const value = object[name] | 37 | const value = object[name] |
38 | if (!value) continue | 38 | if (!value) continue |
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 40e05fcc7..0ec2a9b15 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -25,7 +25,7 @@ import { VideoAbuseService } from './video-abuse' | |||
25 | import { VideoBlacklistService } from './video-blacklist' | 25 | import { VideoBlacklistService } from './video-blacklist' |
26 | import { VideoOwnershipService } from './video-ownership' | 26 | import { VideoOwnershipService } from './video-ownership' |
27 | import { VideoMiniatureComponent } from './video/video-miniature.component' | 27 | import { VideoMiniatureComponent } from './video/video-miniature.component' |
28 | import { VideoFeedComponent } from './video/video-feed.component' | 28 | import { FeedComponent } from './video/feed.component' |
29 | import { VideoThumbnailComponent } from './video/video-thumbnail.component' | 29 | import { VideoThumbnailComponent } from './video/video-thumbnail.component' |
30 | import { VideoService } from './video/video.service' | 30 | import { VideoService } from './video/video.service' |
31 | import { AccountService } from '@app/shared/account/account.service' | 31 | import { AccountService } from '@app/shared/account/account.service' |
@@ -82,7 +82,7 @@ import { BlocklistService } from '@app/shared/blocklist' | |||
82 | LoaderComponent, | 82 | LoaderComponent, |
83 | VideoThumbnailComponent, | 83 | VideoThumbnailComponent, |
84 | VideoMiniatureComponent, | 84 | VideoMiniatureComponent, |
85 | VideoFeedComponent, | 85 | FeedComponent, |
86 | ButtonComponent, | 86 | ButtonComponent, |
87 | DeleteButtonComponent, | 87 | DeleteButtonComponent, |
88 | EditButtonComponent, | 88 | EditButtonComponent, |
@@ -122,7 +122,7 @@ import { BlocklistService } from '@app/shared/blocklist' | |||
122 | LoaderComponent, | 122 | LoaderComponent, |
123 | VideoThumbnailComponent, | 123 | VideoThumbnailComponent, |
124 | VideoMiniatureComponent, | 124 | VideoMiniatureComponent, |
125 | VideoFeedComponent, | 125 | FeedComponent, |
126 | ButtonComponent, | 126 | ButtonComponent, |
127 | DeleteButtonComponent, | 127 | DeleteButtonComponent, |
128 | EditButtonComponent, | 128 | EditButtonComponent, |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index e6b612054..7c840ffa7 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -43,7 +43,6 @@ export class User implements UserServerModel { | |||
43 | 43 | ||
44 | blocked: boolean | 44 | blocked: boolean |
45 | blockedReason?: string | 45 | blockedReason?: string |
46 | [key: string]: any | ||
47 | 46 | ||
48 | constructor (hash: UserConstructorHash) { | 47 | constructor (hash: UserConstructorHash) { |
49 | this.id = hash.id | 48 | this.id = hash.id |
diff --git a/client/src/app/shared/video/abstract-video-list.html b/client/src/app/shared/video/abstract-video-list.html index 69a619b76..29492351b 100644 --- a/client/src/app/shared/video/abstract-video-list.html +++ b/client/src/app/shared/video/abstract-video-list.html | |||
@@ -3,7 +3,7 @@ | |||
3 | <div *ngIf="titlePage" class="title-page title-page-single"> | 3 | <div *ngIf="titlePage" class="title-page title-page-single"> |
4 | {{ titlePage }} | 4 | {{ titlePage }} |
5 | </div> | 5 | </div> |
6 | <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed> | 6 | <my-feed [syndicationItems]="syndicationItems"></my-feed> |
7 | 7 | ||
8 | <div class="moderation-block" *ngIf="displayModerationBlock"> | 8 | <div class="moderation-block" *ngIf="displayModerationBlock"> |
9 | <my-peertube-checkbox | 9 | <my-peertube-checkbox |
diff --git a/client/src/app/shared/video/abstract-video-list.scss b/client/src/app/shared/video/abstract-video-list.scss index 92998cb44..9fb3fd4d6 100644 --- a/client/src/app/shared/video/abstract-video-list.scss +++ b/client/src/app/shared/video/abstract-video-list.scss | |||
@@ -17,7 +17,7 @@ | |||
17 | margin: 0 5px 0 0; | 17 | margin: 0 5px 0 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | my-video-feed { | 20 | my-feed { |
21 | display: inline-block; | 21 | display: inline-block; |
22 | position: relative; | 22 | position: relative; |
23 | top: 1px; | 23 | top: 1px; |
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 87814d4ba..2d32dd6ad 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -12,6 +12,7 @@ import { Video } from './video.model' | |||
12 | import { I18n } from '@ngx-translate/i18n-polyfill' | 12 | import { I18n } from '@ngx-translate/i18n-polyfill' |
13 | import { ScreenService } from '@app/shared/misc/screen.service' | 13 | import { ScreenService } from '@app/shared/misc/screen.service' |
14 | import { OwnerDisplayType } from '@app/shared/video/video-miniature.component' | 14 | import { OwnerDisplayType } from '@app/shared/video/video-miniature.component' |
15 | import { Syndication } from '@app/shared/video/syndication.model' | ||
15 | 16 | ||
16 | export abstract class AbstractVideoList implements OnInit, OnDestroy { | 17 | export abstract class AbstractVideoList implements OnInit, OnDestroy { |
17 | private static LINES_PER_PAGE = 4 | 18 | private static LINES_PER_PAGE = 4 |
@@ -27,7 +28,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
27 | sort: VideoSortField = '-publishedAt' | 28 | sort: VideoSortField = '-publishedAt' |
28 | categoryOneOf?: number | 29 | categoryOneOf?: number |
29 | defaultSort: VideoSortField = '-publishedAt' | 30 | defaultSort: VideoSortField = '-publishedAt' |
30 | syndicationItems: any = [] | 31 | syndicationItems: Syndication[] = [] |
31 | 32 | ||
32 | loadOnInit = true | 33 | loadOnInit = true |
33 | marginContent = true | 34 | marginContent = true |
@@ -59,7 +60,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
59 | private resizeSubscription: Subscription | 60 | private resizeSubscription: Subscription |
60 | 61 | ||
61 | abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}> | 62 | abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}> |
62 | abstract generateSyndicationList (): any | 63 | abstract generateSyndicationList (): void |
63 | 64 | ||
64 | get user () { | 65 | get user () { |
65 | return this.authService.getUser() | 66 | return this.authService.getUser() |
@@ -209,9 +210,11 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
209 | } | 210 | } |
210 | 211 | ||
211 | protected setNewRouteParams () { | 212 | protected setNewRouteParams () { |
212 | const paramsObject: any = this.buildRouteParams() | 213 | const paramsObject = this.buildRouteParams() |
213 | 214 | ||
214 | const queryParams = Object.keys(paramsObject).map(p => p + '=' + paramsObject[p]).join('&') | 215 | const queryParams = Object.keys(paramsObject) |
216 | .map(p => p + '=' + paramsObject[p]) | ||
217 | .join('&') | ||
215 | this.location.replaceState(this.currentRoute, queryParams) | 218 | this.location.replaceState(this.currentRoute, queryParams) |
216 | } | 219 | } |
217 | 220 | ||
diff --git a/client/src/app/shared/video/video-feed.component.html b/client/src/app/shared/video/feed.component.html index 16116ba88..16116ba88 100644 --- a/client/src/app/shared/video/video-feed.component.html +++ b/client/src/app/shared/video/feed.component.html | |||
diff --git a/client/src/app/shared/video/video-feed.component.scss b/client/src/app/shared/video/feed.component.scss index 385764be0..385764be0 100644 --- a/client/src/app/shared/video/video-feed.component.scss +++ b/client/src/app/shared/video/feed.component.scss | |||
diff --git a/client/src/app/shared/video/feed.component.ts b/client/src/app/shared/video/feed.component.ts new file mode 100644 index 000000000..12507458f --- /dev/null +++ b/client/src/app/shared/video/feed.component.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { Syndication } from '@app/shared/video/syndication.model' | ||
3 | |||
4 | @Component({ | ||
5 | selector: 'my-feed', | ||
6 | styleUrls: [ './feed.component.scss' ], | ||
7 | templateUrl: './feed.component.html' | ||
8 | }) | ||
9 | export class FeedComponent { | ||
10 | @Input() syndicationItems: Syndication[] | ||
11 | } | ||
diff --git a/client/src/app/shared/video/syndication.model.ts b/client/src/app/shared/video/syndication.model.ts new file mode 100644 index 000000000..a52b5771b --- /dev/null +++ b/client/src/app/shared/video/syndication.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' | ||
2 | |||
3 | export interface Syndication { | ||
4 | format: FeedFormat, | ||
5 | label: string, | ||
6 | url: string | ||
7 | } \ No newline at end of file | ||
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index a62277e04..fc772a3cf 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts | |||
@@ -25,7 +25,6 @@ export class VideoEdit implements VideoUpdate { | |||
25 | uuid?: string | 25 | uuid?: string |
26 | id?: number | 26 | id?: number |
27 | scheduleUpdate?: VideoScheduleUpdate | 27 | scheduleUpdate?: VideoScheduleUpdate |
28 | [key: string]: any | ||
29 | 28 | ||
30 | constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { | 29 | constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { |
31 | if (video) { | 30 | if (video) { |
@@ -50,14 +49,14 @@ export class VideoEdit implements VideoUpdate { | |||
50 | } | 49 | } |
51 | } | 50 | } |
52 | 51 | ||
53 | patch (values: any) { | 52 | patch (values: { [ id: string ]: string }) { |
54 | Object.keys(values).forEach((key) => { | 53 | Object.keys(values).forEach((key) => { |
55 | this[ key ] = values[ key ] | 54 | this[ key ] = values[ key ] |
56 | }) | 55 | }) |
57 | 56 | ||
58 | // If schedule publication, the video is private and will be changed to public privacy | 57 | // If schedule publication, the video is private and will be changed to public privacy |
59 | if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) { | 58 | if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) { |
60 | const updateAt = (values['schedulePublicationAt'] as Date) | 59 | const updateAt = new Date(values['schedulePublicationAt']) |
61 | updateAt.setSeconds(0) | 60 | updateAt.setSeconds(0) |
62 | 61 | ||
63 | this.privacy = VideoPrivacy.PRIVATE | 62 | this.privacy = VideoPrivacy.PRIVATE |
diff --git a/client/src/app/shared/video/video-feed.component.ts b/client/src/app/shared/video/video-feed.component.ts deleted file mode 100644 index be6c80c3f..000000000 --- a/client/src/app/shared/video/video-feed.component.ts +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | selector: 'my-video-feed', | ||
5 | styleUrls: [ './video-feed.component.scss' ], | ||
6 | templateUrl: './video-feed.component.html' | ||
7 | }) | ||
8 | export class VideoFeedComponent { | ||
9 | @Input() syndicationItems: any | ||
10 | } | ||
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 6283cf84d..65297d7a1 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -274,9 +274,9 @@ export class VideoService implements VideosProvider { | |||
274 | 274 | ||
275 | loadCompleteDescription (descriptionPath: string) { | 275 | loadCompleteDescription (descriptionPath: string) { |
276 | return this.authHttp | 276 | return this.authHttp |
277 | .get(environment.apiUrl + descriptionPath) | 277 | .get<{ description: string }>(environment.apiUrl + descriptionPath) |
278 | .pipe( | 278 | .pipe( |
279 | map((res: any) => res[ 'description' ]), | 279 | map(res => res.description), |
280 | catchError(err => this.restExtractor.handleError(err)) | 280 | catchError(err => this.restExtractor.handleError(err)) |
281 | ) | 281 | ) |
282 | } | 282 | } |