From c199c427d4ae586339822320f20f512a7a19dc3f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 14:35:31 +0200 Subject: Better typings --- .../edit-custom-config.component.ts | 4 ++-- client/src/app/+admin/users/user-edit/user-edit.ts | 2 +- .../app/+admin/users/user-list/user-list.component.ts | 6 +++--- .../my-account-video-channel-update.component.ts | 6 ++---- .../my-account-videos/my-account-videos.component.ts | 11 +++++------ .../video-change-ownership.component.ts | 3 +-- .../+my-account/shared/actor-avatar-info.component.ts | 4 ++-- client/src/app/core/auth/auth.service.ts | 2 +- client/src/app/core/server/server.service.ts | 4 ++-- client/src/app/menu/menu.component.ts | 2 +- client/src/app/search/advanced-search.model.ts | 4 ++-- .../app/shared/buttons/action-dropdown.component.ts | 6 +++--- client/src/app/shared/buttons/button.component.ts | 6 +++--- .../src/app/shared/buttons/edit-button.component.ts | 2 +- .../app/shared/guards/can-deactivate-guard.service.ts | 4 +++- client/src/app/shared/misc/help.component.ts | 2 +- client/src/app/shared/rest/rest-extractor.service.ts | 4 ++-- client/src/app/shared/rest/rest.service.ts | 2 +- client/src/app/shared/shared.module.ts | 6 +++--- client/src/app/shared/users/user.model.ts | 1 - client/src/app/shared/video/abstract-video-list.html | 2 +- client/src/app/shared/video/abstract-video-list.scss | 2 +- client/src/app/shared/video/abstract-video-list.ts | 11 +++++++---- client/src/app/shared/video/feed.component.html | 10 ++++++++++ client/src/app/shared/video/feed.component.scss | 19 +++++++++++++++++++ client/src/app/shared/video/feed.component.ts | 11 +++++++++++ client/src/app/shared/video/syndication.model.ts | 7 +++++++ client/src/app/shared/video/video-edit.model.ts | 5 ++--- client/src/app/shared/video/video-feed.component.html | 10 ---------- client/src/app/shared/video/video-feed.component.scss | 19 ------------------- client/src/app/shared/video/video-feed.component.ts | 10 ---------- client/src/app/shared/video/video.service.ts | 4 ++-- .../shared/video-caption-add-modal.component.ts | 5 +++-- .../video-import-torrent.component.ts | 6 +++--- .../+video-edit/video-add-components/video-send.ts | 6 +++--- .../video-add-components/video-upload.component.ts | 6 +++--- .../videos/+video-watch/comment/linkifier.service.ts | 1 + .../+video-watch/comment/video-comment.component.ts | 2 +- .../+video-watch/comment/video-comment.service.ts | 8 ++++---- .../comment/video-comments.component.html | 2 +- .../comment/video-comments.component.scss | 2 +- .../+video-watch/comment/video-comments.component.ts | 3 ++- .../videos/+video-watch/video-watch.component.scss | 2 +- .../app/videos/+video-watch/video-watch.component.ts | 16 +++++++++------- 44 files changed, 131 insertions(+), 119 deletions(-) create mode 100644 client/src/app/shared/video/feed.component.html create mode 100644 client/src/app/shared/video/feed.component.scss create mode 100644 client/src/app/shared/video/feed.component.ts create mode 100644 client/src/app/shared/video/syndication.model.ts delete mode 100644 client/src/app/shared/video/video-feed.component.html delete mode 100644 client/src/app/shared/video/video-feed.component.scss delete mode 100644 client/src/app/shared/video/video-feed.component.ts (limited to 'client/src/app') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 9a9298825..f48b6fc1a 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -62,7 +62,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } ngOnInit () { - const formGroupData: any = { + const formGroupData: { [key: string]: any } = { instanceName: this.customConfigValidatorsService.INSTANCE_NAME, instanceShortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION, instanceDescription: null, @@ -202,7 +202,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } private updateForm () { - const data: any = { + const data: { [key: string]: any } = { instanceName: this.customConfig.instance.name, instanceShortDescription: this.customConfig.instance.shortDescription, instanceDescription: this.customConfig.instance.description, diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts index a4d696e69..99ce5804b 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -7,7 +7,7 @@ export abstract class UserEdit extends FormReactive { videoQuotaOptions: { value: string, label: string }[] = [] videoQuotaDailyOptions: { value: string, label: string }[] = [] - roles = Object.keys(USER_ROLE_LABELS).map((key: any) => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) + roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) protected abstract serverService: ServerService protected abstract configService: ConfigService diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index 0d7f88d2b..3859af9ff 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts @@ -23,7 +23,7 @@ export class UserListComponent extends RestTable implements OnInit { pagination: RestPagination = { count: this.rowsPerPage, start: 0 } selectedUsers: User[] = [] - bulkUserActions: DropdownAction[] = [] + bulkUserActions: DropdownAction[] = [] constructor ( private notificationsService: NotificationsService, @@ -45,12 +45,12 @@ export class UserListComponent extends RestTable implements OnInit { { label: this.i18n('Ban'), handler: users => this.openBanUserModal(users), - isDisplayed: users => users.every((u: any) => u.blocked === false) + isDisplayed: users => users.every(u => u.blocked === false) }, { label: this.i18n('Unban'), handler: users => this.unbanUsers(users), - isDisplayed: users => users.every((u: any) => u.blocked === true) + isDisplayed: users => users.every(u => u.blocked === true) } ] } diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts index f2b8a4e26..5d43956f2 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { NotificationsService } from 'angular2-notifications' import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' @@ -17,11 +17,9 @@ import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators styleUrls: [ './my-account-video-channel-edit.component.scss' ] }) export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { - @ViewChild('avatarfileInput') avatarfileInput: any - error: string - videoChannelToUpdate: VideoChannel + private paramsSub: Subscription constructor ( diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts index 52307f09e..2d88ac760 100644 --- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts +++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts @@ -66,7 +66,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni } isInSelectionMode () { - return Object.keys(this.checkedVideos).some((k: any) => this.checkedVideos[ k ] === true) + return Object.keys(this.checkedVideos).some(k => this.checkedVideos[ k ] === true) } getVideosObservable (page: number) { @@ -81,7 +81,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni async deleteSelectedVideos () { const toDeleteVideosIds = Object.keys(this.checkedVideos) - .filter((k: any) => this.checkedVideos[ k ] === true) + .filter(k => this.checkedVideos[ k ] === true) .map(k => parseInt(k, 10)) const res = await this.confirmService.confirm( @@ -168,10 +168,9 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni } private spliceVideosById (id: number) { - let key: any - for (key of Object.keys(this.loadedPages)) { - const videos = this.loadedPages[ key ] - const index = videos.findIndex((v: any) => v.id === id) + for (const key of Object.keys(this.loadedPages)) { + const videos: Video[] = this.loadedPages[ key ] + const index = videos.findIndex(v => v.id === id) if (index !== -1) { videos.splice(index, 1) diff --git a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts index eb3f9404f..9f94f3c13 100644 --- a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts +++ b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts @@ -49,8 +49,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni .catch((_) => _) // Called when closing (cancel) the modal without validating, do nothing } - // TODO: typing - search (event: any) { + search (event: { query: string }) { const query = event.query this.userService.autocomplete(query) .subscribe( diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.ts b/client/src/app/+my-account/shared/actor-avatar-info.component.ts index b4505a7f2..54bacc212 100644 --- a/client/src/app/+my-account/shared/actor-avatar-info.component.ts +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core' +import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core' import { ServerService } from '../../core/server' import { NotificationsService } from 'angular2-notifications' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' @@ -10,7 +10,7 @@ import { Account } from '@app/shared/account/account.model' styleUrls: [ './actor-avatar-info.component.scss' ] }) export class ActorAvatarInfoComponent { - @ViewChild('avatarfileInput') avatarfileInput: any + @ViewChild('avatarfileInput') avatarfileInput: ElementRef @Input() actor: VideoChannel | Account diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 5315c8b1d..443772c9e 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -221,7 +221,7 @@ export class AuthService { } refreshUserInformation () { - const obj: any = { + const obj: UserLoginWithUsername = { access_token: this.user.getAccessToken(), refresh_token: null, token_type: this.user.getTokenType(), diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 1663a052c..da8bd26db 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -154,8 +154,8 @@ export class ServerService { this.localeObservable .pipe( switchMap(translations => { - return this.http.get(ServerService.BASE_VIDEO_URL + attributeName) - .pipe(map((data: any) => ({ data, translations }))) + return this.http.get<{ [id: string]: string }>(ServerService.BASE_VIDEO_URL + attributeName) + .pipe(map(data => ({ data, translations }))) }) ) .subscribe(({ data, translations }) => { diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 348700c09..371beb4a5 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -18,7 +18,7 @@ export class MenuComponent implements OnInit { userHasAdminAccess = false helpVisible = false - private routesPerRight: any = { + private routesPerRight: { [ role in UserRight ]?: string } = { [UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/moderation/video-abuses', diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts index 1d6c89282..033fa9bba 100644 --- a/client/src/app/search/advanced-search.model.ts +++ b/client/src/app/search/advanced-search.model.ts @@ -53,7 +53,7 @@ export class AdvancedSearch { } containsValues () { - const obj: any = this.toUrlObject() + const obj = this.toUrlObject() for (const k of Object.keys(obj)) { if (k === 'sort') continue // Exception @@ -113,7 +113,7 @@ export class AdvancedSearch { size () { let acc = 0 - const obj: any = this.toUrlObject() + const obj = this.toUrlObject() for (const k of Object.keys(obj)) { if (k === 'sort') continue // Exception 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' export type DropdownAction = { label?: string - handler?: (T: any) => any - linkBuilder?: (T: any) => (string | number)[] - isDisplayed?: (T: any) => boolean + handler?: (a: T) => any + linkBuilder?: (a: T) => (string | number)[] + isDisplayed?: (a: T) => boolean } @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' export class ButtonComponent { @Input() label = '' - @Input() className: any = undefined - @Input() icon: any = undefined - @Input() title: any = undefined + @Input() className: string = undefined + @Input() icon: string = undefined + @Input() title: string = undefined getTitle () { 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' export class EditButtonComponent { @Input() label: string - @Input() routerLink: any = [] + @Input() routerLink: string[] = [] } 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' import { ConfirmService } from '../../core/index' import { I18n } from '@ngx-translate/i18n-polyfill' +export type CanComponentDeactivateResult = { text?: string, canDeactivate: Observable | boolean } + export interface CanComponentDeactivate { - canDeactivate: () => { text?: string, canDeactivate: Observable | boolean } + canDeactivate: () => CanComponentDeactivateResult } @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 { } private createMarkdownList (rules: string[]) { - const rulesToText: any = { + const rulesToText = { 'emphasis': this.i18n('Emphasis'), 'link': this.i18n('Links'), '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 { return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) } - convertDateToHuman (target: any, fieldsToConvert: string[]) { + convertDateToHuman (target: { [ id: string ]: string }, fieldsToConvert: string[]) { fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) return target @@ -83,7 +83,7 @@ export class RestExtractor { errorMessage = err } - const errorObj: any = { + const errorObj: { message: string, status: string, body: string } = { message: errorMessage, status: undefined, 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 { return newParams } - addObjectParams (params: HttpParams, object: any) { + addObjectParams (params: HttpParams, object: { [ name: string ]: any }) { for (const name of Object.keys(object)) { const value = object[name] 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' import { VideoBlacklistService } from './video-blacklist' import { VideoOwnershipService } from './video-ownership' import { VideoMiniatureComponent } from './video/video-miniature.component' -import { VideoFeedComponent } from './video/video-feed.component' +import { FeedComponent } from './video/feed.component' import { VideoThumbnailComponent } from './video/video-thumbnail.component' import { VideoService } from './video/video.service' import { AccountService } from '@app/shared/account/account.service' @@ -82,7 +82,7 @@ import { BlocklistService } from '@app/shared/blocklist' LoaderComponent, VideoThumbnailComponent, VideoMiniatureComponent, - VideoFeedComponent, + FeedComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent, @@ -122,7 +122,7 @@ import { BlocklistService } from '@app/shared/blocklist' LoaderComponent, VideoThumbnailComponent, VideoMiniatureComponent, - VideoFeedComponent, + FeedComponent, ButtonComponent, DeleteButtonComponent, 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 { blocked: boolean blockedReason?: string - [key: string]: any constructor (hash: UserConstructorHash) { 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 @@
{{ titlePage }}
- +
- abstract generateSyndicationList (): any + abstract generateSyndicationList (): void get user () { return this.authService.getUser() @@ -209,9 +210,11 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { } protected setNewRouteParams () { - const paramsObject: any = this.buildRouteParams() + const paramsObject = this.buildRouteParams() - const queryParams = Object.keys(paramsObject).map(p => p + '=' + paramsObject[p]).join('&') + const queryParams = Object.keys(paramsObject) + .map(p => p + '=' + paramsObject[p]) + .join('&') this.location.replaceState(this.currentRoute, queryParams) } diff --git a/client/src/app/shared/video/feed.component.html b/client/src/app/shared/video/feed.component.html new file mode 100644 index 000000000..16116ba88 --- /dev/null +++ b/client/src/app/shared/video/feed.component.html @@ -0,0 +1,10 @@ +
+ + + + {{ item.label }} + +
\ No newline at end of file diff --git a/client/src/app/shared/video/feed.component.scss b/client/src/app/shared/video/feed.component.scss new file mode 100644 index 000000000..385764be0 --- /dev/null +++ b/client/src/app/shared/video/feed.component.scss @@ -0,0 +1,19 @@ +@import '_mixins'; + +.video-feed { + a { + color: black; + display: block; + } + + .icon { + @include icon(12px); + + &.icon-syndication { + position: relative; + top: -2px; + background-color: var(--mainForegroundColor); + mask-image: url('../../../assets/images/global/syndication.svg'); + } + } +} \ No newline at end of file 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 @@ +import { Component, Input } from '@angular/core' +import { Syndication } from '@app/shared/video/syndication.model' + +@Component({ + selector: 'my-feed', + styleUrls: [ './feed.component.scss' ], + templateUrl: './feed.component.html' +}) +export class FeedComponent { + @Input() syndicationItems: Syndication[] +} 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 @@ +import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' + +export interface Syndication { + format: FeedFormat, + label: string, + url: string +} \ 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 { uuid?: string id?: number scheduleUpdate?: VideoScheduleUpdate - [key: string]: any constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { if (video) { @@ -50,14 +49,14 @@ export class VideoEdit implements VideoUpdate { } } - patch (values: any) { + patch (values: { [ id: string ]: string }) { Object.keys(values).forEach((key) => { this[ key ] = values[ key ] }) // If schedule publication, the video is private and will be changed to public privacy if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) { - const updateAt = (values['schedulePublicationAt'] as Date) + const updateAt = new Date(values['schedulePublicationAt']) updateAt.setSeconds(0) this.privacy = VideoPrivacy.PRIVATE diff --git a/client/src/app/shared/video/video-feed.component.html b/client/src/app/shared/video/video-feed.component.html deleted file mode 100644 index 16116ba88..000000000 --- a/client/src/app/shared/video/video-feed.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - - - {{ item.label }} - -
\ No newline at end of file diff --git a/client/src/app/shared/video/video-feed.component.scss b/client/src/app/shared/video/video-feed.component.scss deleted file mode 100644 index 385764be0..000000000 --- a/client/src/app/shared/video/video-feed.component.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import '_mixins'; - -.video-feed { - a { - color: black; - display: block; - } - - .icon { - @include icon(12px); - - &.icon-syndication { - position: relative; - top: -2px; - background-color: var(--mainForegroundColor); - mask-image: url('../../../assets/images/global/syndication.svg'); - } - } -} \ No newline at end of file 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 @@ -import { Component, Input } from '@angular/core' - -@Component({ - selector: 'my-video-feed', - styleUrls: [ './video-feed.component.scss' ], - templateUrl: './video-feed.component.html' -}) -export class VideoFeedComponent { - @Input() syndicationItems: any -} 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 { loadCompleteDescription (descriptionPath: string) { return this.authHttp - .get(environment.apiUrl + descriptionPath) + .get<{ description: string }>(environment.apiUrl + descriptionPath) .pipe( - map((res: any) => res[ 'description' ]), + map(res => res.description), catchError(err => this.restExtractor.handleError(err)) ) } diff --git a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts index a2c9237ad..796fbe531 100644 --- a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -5,6 +5,7 @@ import { VideoCaptionsValidatorsService } from '@app/shared/forms/form-validator import { ServerService } from '@app/core' import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' +import { VideoConstant } from '../../../../../../shared' @Component({ selector: 'my-video-caption-add-modal', @@ -19,7 +20,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni @ViewChild('modal') modal: ElementRef - videoCaptionLanguages: any = [] + videoCaptionLanguages: VideoConstant[] = [] private openedModal: NgbModalRef private closingModal = false @@ -73,7 +74,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni this.hide() const languageId = this.form.value[ 'language' ] - const languageObject = this.videoCaptionLanguages.find((l: any) => l.id === languageId) + const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId) this.captionAdded.emit({ language: languageObject, diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts index 9a50e2ab2..e13c06ce9 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' +import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' import { NotificationsService } from 'angular2-notifications' import { VideoPrivacy, VideoUpdate } from '../../../../../../shared/models/videos' @@ -23,7 +23,7 @@ import { VideoImportService } from '@app/shared/video-import' }) export class VideoImportTorrentComponent extends VideoSend implements OnInit, CanComponentDeactivate { @Output() firstStepDone = new EventEmitter() - @ViewChild('torrentfileInput') torrentfileInput: any + @ViewChild('torrentfileInput') torrentfileInput: ElementRef videoFileName: string magnetUri = '' @@ -64,7 +64,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca } fileChange () { - const torrentfile = this.torrentfileInput.nativeElement.files[0] as File + const torrentfile = this.torrentfileInput.nativeElement.files[0] if (!torrentfile) return this.importVideo(torrentfile) diff --git a/client/src/app/videos/+video-edit/video-add-components/video-send.ts b/client/src/app/videos/+video-edit/video-add-components/video-send.ts index cf9d47cbe..1bf22e1a9 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-send.ts @@ -3,7 +3,6 @@ import { LoadingBarService } from '@ngx-loading-bar/core' import { NotificationsService } from 'angular2-notifications' import { catchError, switchMap, tap } from 'rxjs/operators' import { FormReactive } from '@app/shared' -import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' import { VideoConstant, VideoPrivacy } from '../../../../../../shared' import { AuthService, ServerService } from '@app/core' import { VideoService } from '@app/shared/video/video.service' @@ -11,8 +10,9 @@ import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.m import { VideoCaptionService } from '@app/shared/video-caption' import { VideoEdit } from '@app/shared/video/video-edit.model' import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils' +import { CanComponentDeactivateResult } from '@app/shared/guards/can-deactivate-guard.service' -export abstract class VideoSend extends FormReactive implements OnInit, CanComponentDeactivate { +export abstract class VideoSend extends FormReactive implements OnInit { userVideoChannels: { id: number, label: string, support: string }[] = [] videoPrivacies: VideoConstant[] = [] videoCaptions: VideoCaptionEdit[] = [] @@ -30,7 +30,7 @@ export abstract class VideoSend extends FormReactive implements OnInit, CanCompo protected videoService: VideoService protected videoCaptionService: VideoCaptionService - abstract canDeactivate (): any + abstract canDeactivate (): CanComponentDeactivateResult ngOnInit () { this.buildForm({}) diff --git a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts index fa6ee0c23..8e2d0deaf 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts @@ -1,5 +1,5 @@ import { HttpEventType, HttpResponse } from '@angular/common/http' -import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' +import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' import { LoadingBarService } from '@ngx-loading-bar/core' import { NotificationsService } from 'angular2-notifications' @@ -25,7 +25,7 @@ import { VideoCaptionService } from '@app/shared/video-caption' }) export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy, CanComponentDeactivate { @Output() firstStepDone = new EventEmitter() - @ViewChild('videofileInput') videofileInput: any + @ViewChild('videofileInput') videofileInput: ElementRef // So that it can be accessed in the template readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY @@ -110,7 +110,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy } uploadFirstStep () { - const videofile = this.videofileInput.nativeElement.files[0] as File + const videofile = this.videofileInput.nativeElement.files[0] if (!videofile) return // Cannot upload videos > 8GB for now diff --git a/client/src/app/videos/+video-watch/comment/linkifier.service.ts b/client/src/app/videos/+video-watch/comment/linkifier.service.ts index 9ad419a69..4f4ec1e5d 100644 --- a/client/src/app/videos/+video-watch/comment/linkifier.service.ts +++ b/client/src/app/videos/+video-watch/comment/linkifier.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core' import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' +// FIXME: use @types/linkify when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29682/files is merged? const linkify = require('linkifyjs') const linkifyHtml = require('linkifyjs/html') diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index 982470786..00f0460a1 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -26,7 +26,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Output() resetReply = new EventEmitter() sanitizedCommentHTML = '' - newParentComments: any = [] + newParentComments: VideoComment[] = [] constructor ( private linkifierService: LinkifierService, diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index 7d9c2d0ad..921447d5b 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -30,9 +30,9 @@ export class VideoCommentService { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, normalizedComment) + return this.authHttp.post<{ comment: VideoCommentServerModel }>(url, normalizedComment) .pipe( - map((data: any) => this.extractVideoComment(data['comment'])), + map(data => this.extractVideoComment(data.comment)), catchError(err => this.restExtractor.handleError(err)) ) } @@ -41,9 +41,9 @@ export class VideoCommentService { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comments/' + inReplyToCommentId const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, normalizedComment) + return this.authHttp.post<{ comment: VideoCommentServerModel }>(url, normalizedComment) .pipe( - map((data: any) => this.extractVideoComment(data[ 'comment' ])), + map(data => this.extractVideoComment(data.comment)), catchError(err => this.restExtractor.handleError(err)) ) } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html index 42e129d65..44016d8ad 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html @@ -4,7 +4,7 @@ Comments
- + diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.scss b/client/src/app/videos/+video-watch/comment/video-comments.component.scss index dbb44c66c..575e331e4 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.scss +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.scss @@ -23,7 +23,7 @@ margin-right: 0; } -my-video-feed { +my-feed { display: inline-block; margin-left: 5px; } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 4c1bdf2dd..8850eccd8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -12,6 +12,7 @@ import { VideoDetails } from '../../../shared/video/video-details.model' import { VideoComment } from './video-comment.model' import { VideoCommentService } from './video-comment.service' import { I18n } from '@ngx-translate/i18n-polyfill' +import { Syndication } from '@app/shared/video/syndication.model' @Component({ selector: 'my-video-comments', @@ -35,7 +36,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { threadComments: { [ id: number ]: VideoCommentThreadTree } = {} threadLoading: { [ id: number ]: boolean } = {} - syndicationItems: any = [] + syndicationItems: Syndication[] = [] private sub: Subscription diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss index f31e4694a..2586a2204 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss @@ -162,7 +162,7 @@ $other-videos-width: 260px; } } - my-video-feed { + my-feed { margin-left: 5px; margin-top: 1px; } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index ed5e723c9..65b974037 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -7,7 +7,9 @@ import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-supp import { MetaService } from '@ngx-meta/core' import { NotificationsService } from 'angular2-notifications' import { forkJoin, Subscription } from 'rxjs' -const videojs = require('video.js') +// FIXME: something weird with our path definition in tsconfig and typings +// @ts-ignore +import videojs from 'video.js' import 'videojs-hotkeys' import { Hotkey, HotkeysService } from 'angular2-hotkeys' import * as WebTorrent from 'webtorrent' @@ -45,7 +47,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent - player: any + player: videojs.Player playerElement: HTMLVideoElement userRating: UserVideoRateType = null video: VideoDetails = null @@ -435,7 +437,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.zone.runOutsideAngular(async () => { videojs(this.playerElement, videojsOptions, function () { self.player = this - this.on('customError', (data: any) => self.handleError(data.err)) + this.on('customError', ({ err }: { err: any }) => self.handleError(err)) addContextMenu(self.player, self.video.embedUrl) }) @@ -448,7 +450,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.checkUserRating() } - private setRating (nextRating: string) { + private setRating (nextRating: VideoRateType) { let method switch (nextRating) { case 'like': @@ -466,11 +468,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { .subscribe( () => { // Update the video like attribute - this.updateVideoRating(this.userRating, nextRating as VideoRateType) - this.userRating = nextRating as UserVideoRateType + this.updateVideoRating(this.userRating, nextRating) + this.userRating = nextRating }, - (err: any) => this.notificationsService.error(this.i18n('Error'), err.message) + (err: { message: string }) => this.notificationsService.error(this.i18n('Error'), err.message) ) } -- cgit v1.2.3