From 3a0fb65c61f80b510bce979a45d59d17948745e8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Apr 2019 10:52:27 +0200 Subject: [PATCH] Add video miniature dropdown --- .../my-account-history.component.html | 4 +- client/src/app/search/search.component.html | 5 +- client/src/app/search/search.component.ts | 6 +- .../buttons/action-dropdown.component.html | 21 +- .../buttons/action-dropdown.component.scss | 25 +- .../buttons/action-dropdown.component.ts | 25 +- client/src/app/shared/misc/screen.service.ts | 2 + client/src/app/shared/shared.module.ts | 19 ++ .../video-add-to-playlist.component.html | 112 +++++---- .../video-add-to-playlist.component.scss | 5 + .../video-add-to-playlist.component.ts | 5 + .../app/shared/video/abstract-video-list.html | 10 +- .../app/shared/video/abstract-video-list.ts | 6 +- .../modals}/video-blacklist.component.html | 0 .../modals}/video-blacklist.component.scss | 0 .../modals}/video-blacklist.component.ts | 13 +- .../modals}/video-download.component.html | 0 .../modals}/video-download.component.scss | 0 .../video/modals}/video-download.component.ts | 43 ++-- .../video/modals}/video-report.component.html | 0 .../video/modals}/video-report.component.scss | 0 .../video/modals}/video-report.component.ts | 3 +- .../video-actions-dropdown.component.html | 21 ++ .../video-actions-dropdown.component.scss | 12 + .../video/video-actions-dropdown.component.ts | 237 ++++++++++++++++++ .../app/shared/video/video-details.model.ts | 16 -- .../video/video-miniature.component.html | 89 ++++--- .../video/video-miniature.component.scss | 36 +++ .../shared/video/video-miniature.component.ts | 70 ++++-- client/src/app/shared/video/video.model.ts | 19 +- .../video/videos-selection.component.html | 2 +- .../+video-watch/video-watch.component.html | 37 +-- .../+video-watch/video-watch.component.scss | 12 +- .../+video-watch/video-watch.component.ts | 75 +----- .../videos/+video-watch/video-watch.module.ts | 8 - .../video-list/video-overview.component.html | 6 +- 36 files changed, 643 insertions(+), 301 deletions(-) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-blacklist.component.html (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-blacklist.component.scss (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-blacklist.component.ts (82%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-download.component.html (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-download.component.scss (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-download.component.ts (67%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-report.component.html (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-report.component.scss (100%) rename client/src/app/{videos/+video-watch/modal => shared/video/modals}/video-report.component.ts (95%) create mode 100644 client/src/app/shared/video/video-actions-dropdown.component.html create mode 100644 client/src/app/shared/video/video-actions-dropdown.component.scss create mode 100644 client/src/app/shared/video/video-actions-dropdown.component.ts diff --git a/client/src/app/+my-account/my-account-history/my-account-history.component.html b/client/src/app/+my-account/my-account-history/my-account-history.component.html index 4b94490a0..6e274f689 100644 --- a/client/src/app/+my-account/my-account-history/my-account-history.component.html +++ b/client/src/app/+my-account/my-account-history/my-account-history.component.html @@ -15,6 +15,8 @@
- +
diff --git a/client/src/app/search/search.component.html b/client/src/app/search/search.component.html index da2ace54d..0a9f78cb2 100644 --- a/client/src/app/search/search.component.html +++ b/client/src/app/search/search.component.html @@ -48,7 +48,10 @@
- +
diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index a3383ed8a..a7ddbe1f8 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts @@ -1,6 +1,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' -import { AuthService, Notifier, ServerService } from '@app/core' +import { AuthService, Notifier } from '@app/core' import { forkJoin, Subscription } from 'rxjs' import { SearchService } from '@app/search/search.service' import { ComponentPagination } from '@app/shared/rest/component-pagination.model' @@ -138,6 +138,10 @@ export class SearchComponent implements OnInit, OnDestroy { return this.advancedSearch.size() } + removeVideoFromArray (video: Video) { + this.results = this.results.filter(r => !this.isVideo(r) || r.id !== video.id) + } + private resetPagination () { this.pagination.currentPage = 1 this.pagination.totalItems = null diff --git a/client/src/app/shared/buttons/action-dropdown.component.html b/client/src/app/shared/buttons/action-dropdown.component.html index 6999474d6..cc244dc76 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.html +++ b/client/src/app/shared/buttons/action-dropdown.component.html @@ -1,9 +1,11 @@ diff --git a/client/src/app/shared/buttons/action-dropdown.component.scss b/client/src/app/shared/buttons/action-dropdown.component.scss index 985b2ca88..5073190b0 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.scss +++ b/client/src/app/shared/buttons/action-dropdown.component.scss @@ -8,12 +8,19 @@ .action-button { @include peertube-button; - &.grey { - @include grey-button; - } + &.button-styled { + + &.grey { + @include grey-button; + } + + &.orange { + @include orange-button; + } - &.orange { - @include orange-button; + &:hover, &:active, &:focus { + background-color: $grey-background-color; + } } display: inline-block; @@ -23,10 +30,6 @@ display: none; } - &:hover, &:active, &:focus { - background-color: $grey-background-color; - } - .more-icon { width: 21px; } @@ -48,6 +51,10 @@ cursor: pointer; color: #000 !important; + &.with-icon { + @include dropdown-with-icon-item; + } + a, span { display: block; width: 100%; diff --git a/client/src/app/shared/buttons/action-dropdown.component.ts b/client/src/app/shared/buttons/action-dropdown.component.ts index 275e2b51e..f5345831b 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.ts +++ b/client/src/app/shared/buttons/action-dropdown.component.ts @@ -1,12 +1,18 @@ import { Component, Input } from '@angular/core' +import { GlobalIconName } from '@app/shared/images/global-icon.component' export type DropdownAction = { label?: string + iconName?: GlobalIconName handler?: (a: T) => any linkBuilder?: (a: T) => (string | number)[] isDisplayed?: (a: T) => boolean } +export type DropdownButtonSize = 'normal' | 'small' +export type DropdownTheme = 'orange' | 'grey' +export type DropdownDirection = 'horizontal' | 'vertical' + @Component({ selector: 'my-action-dropdown', styleUrls: [ './action-dropdown.component.scss' ], @@ -16,14 +22,29 @@ export type DropdownAction = { export class ActionDropdownComponent { @Input() actions: DropdownAction[] | DropdownAction[][] = [] @Input() entry: T + @Input() placement = 'bottom-left' - @Input() buttonSize: 'normal' | 'small' = 'normal' + + @Input() buttonSize: DropdownButtonSize = 'normal' + @Input() buttonDirection: DropdownDirection = 'horizontal' + @Input() buttonStyled = true + @Input() label: string - @Input() theme: 'orange' | 'grey' = 'grey' + @Input() theme: DropdownTheme = 'grey' getActions () { if (this.actions.length !== 0 && Array.isArray(this.actions[0])) return this.actions return [ this.actions ] } + + areActionsDisplayed (actions: DropdownAction[], entry: T) { + return actions.some(a => a.isDisplayed === undefined || a.isDisplayed(entry)) + } + + handleClick (event: Event, action: DropdownAction) { + event.preventDefault() + + // action.handler(entry) + } } diff --git a/client/src/app/shared/misc/screen.service.ts b/client/src/app/shared/misc/screen.service.ts index 1cbc96b14..db481204e 100644 --- a/client/src/app/shared/misc/screen.service.ts +++ b/client/src/app/shared/misc/screen.service.ts @@ -32,6 +32,8 @@ export class ScreenService { } private cacheWindowInnerWidthExpired () { + if (!this.lastFunctionCallTime) return true + return new Date().getTime() > (this.lastFunctionCallTime + this.cacheForMs) } } diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 68225b457..ded65653f 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -80,6 +80,11 @@ import { NumberFormatterPipe } from '@app/shared/angular/number-formatter.pipe' import { ObjectLengthPipe } from '@app/shared/angular/object-length.pipe' import { FromNowPipe } from '@app/shared/angular/from-now.pipe' import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive' +import { VideoActionsDropdownComponent } from '@app/shared/video/video-actions-dropdown.component' +import { VideoBlacklistComponent } from '@app/shared/video/modals/video-blacklist.component' +import { VideoDownloadComponent } from '@app/shared/video/modals/video-download.component' +import { VideoReportComponent } from '@app/shared/video/modals/video-report.component' +import { ClipboardModule } from 'ngx-clipboard' @NgModule({ imports: [ @@ -95,6 +100,8 @@ import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template NgbTabsetModule, NgbTooltipModule, + ClipboardModule, + PrimeSharedModule, InputMaskModule, NgPipesModule @@ -110,6 +117,11 @@ import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template VideoAddToPlaylistComponent, VideoPlaylistElementMiniatureComponent, VideosSelectionComponent, + VideoActionsDropdownComponent, + + VideoDownloadComponent, + VideoReportComponent, + VideoBlacklistComponent, FeedComponent, @@ -158,6 +170,8 @@ import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template NgbTabsetModule, NgbTooltipModule, + ClipboardModule, + PrimeSharedModule, InputMaskModule, BytesPipe, @@ -172,6 +186,11 @@ import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template VideoAddToPlaylistComponent, VideoPlaylistElementMiniatureComponent, VideosSelectionComponent, + VideoActionsDropdownComponent, + + VideoDownloadComponent, + VideoReportComponent, + VideoBlacklistComponent, FeedComponent, diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html index 19b326206..6029b3648 100644 --- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html +++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html @@ -1,74 +1,76 @@ -
-
-
Save to
+
+
+
+
Save to
-
- +
+ - Options + Options +
-
-
-
- +
+
+ - -
+ +
-
- +
+ - + +
-
-