]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Refactor views component
authorChocobozzz <me@florianbigard.com>
Wed, 9 Dec 2020 14:00:02 +0000 (15:00 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 9 Dec 2020 14:33:16 +0000 (15:33 +0100)
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/app/+videos/+video-watch/video-watch.module.ts
client/src/app/shared/shared-video-miniature/shared-video-miniature.module.ts
client/src/app/shared/shared-video-miniature/video-miniature.component.html
client/src/app/shared/shared-video/index.ts [new file with mode: 0644]
client/src/app/shared/shared-video/shared-video.module.ts [new file with mode: 0644]
client/src/app/shared/shared-video/video-views-counter.component.html [new file with mode: 0644]
client/src/app/shared/shared-video/video-views-counter.component.scss [new file with mode: 0644]
client/src/app/shared/shared-video/video-views-counter.component.ts [new file with mode: 0644]
server/tests/api/live/live.ts

index 602214ac58cc66936a8c4650d20ac0a6072e24a2..9cabe3bbc327c2ebacdd62da5c418671ddb7ee6e 100644 (file)
 
             <div class="video-info-date-views">
               <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
-
-              <span i18n [title]="video.getExactNumberOfViews()" class="views">
-                • {{ video.views | myNumberFormatter }}
-                <ng-container *ngIf="!video.isLive">views</ng-container>
-                <ng-container *ngIf="video.isLive">viewers</ng-container>
-              </span>
+              •
+              <my-video-views-counter [video]="video"></my-video-views-counter>
             </div>
           </div>
 
index 21aa33b84691aed67c710605f6eed36ec7940da1..fbda9b9c4a7575ea8e82c28c1eb55e229e2652d3 100644 (file)
@@ -5,6 +5,7 @@ import { SharedMainModule } from '@app/shared/shared-main'
 import { SharedModerationModule } from '@app/shared/shared-moderation'
 import { SharedShareModal } from '@app/shared/shared-share-modal'
 import { SharedUserSubscriptionModule } from '@app/shared/shared-user-subscription'
+import { SharedVideoModule } from '@app/shared/shared-video'
 import { SharedVideoCommentModule } from '@app/shared/shared-video-comment'
 import { SharedVideoMiniatureModule } from '@app/shared/shared-video-miniature'
 import { SharedVideoPlaylistModule } from '@app/shared/shared-video-playlist'
@@ -32,7 +33,8 @@ import { VideoWatchComponent } from './video-watch.component'
     SharedModerationModule,
     SharedGlobalIconModule,
     SharedVideoCommentModule,
-    SharedShareModal
+    SharedShareModal,
+    SharedVideoModule
   ],
 
   declarations: [
index 08c8da3dd6f8cc9e7a86976764f739c053d2cdc5..3035bcfb3f9628c20a715ae2ade347ecada08974 100644 (file)
@@ -4,6 +4,7 @@ import { SharedFormModule } from '../shared-forms'
 import { SharedGlobalIconModule } from '../shared-icons'
 import { SharedMainModule } from '../shared-main/shared-main.module'
 import { SharedModerationModule } from '../shared-moderation'
+import { SharedVideoModule } from '../shared-video'
 import { SharedThumbnailModule } from '../shared-thumbnail'
 import { SharedVideoLiveModule } from '../shared-video-live'
 import { SharedVideoPlaylistModule } from '../shared-video-playlist/shared-video-playlist.module'
@@ -20,7 +21,8 @@ import { VideosSelectionComponent } from './videos-selection.component'
     SharedVideoPlaylistModule,
     SharedThumbnailModule,
     SharedGlobalIconModule,
-    SharedVideoLiveModule
+    SharedVideoLiveModule,
+    SharedVideoModule
   ],
 
   declarations: [
index 395a4df970f40707190e372be7787ed7628b66c7..7a6df7b64ea690e9927da4d72693c1ecda354f2d 100644 (file)
@@ -28,9 +28,8 @@
 
             <span class="views" [title]="video.getExactNumberOfViews()">
               <ng-container *ngIf="displayOptions.date && displayOptions.views"> • </ng-container>
-              <ng-container i18n *ngIf="displayOptions.views">
-                {video.views, plural, =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}
-              </ng-container>
+
+              <my-video-views-counter *ngIf="displayOptions.views" [video]="video"></my-video-views-counter>
             </span>
           </span>
 
diff --git a/client/src/app/shared/shared-video/index.ts b/client/src/app/shared/shared-video/index.ts
new file mode 100644 (file)
index 0000000..33a8b56
--- /dev/null
@@ -0,0 +1 @@
+export * from './shared-video.module'
diff --git a/client/src/app/shared/shared-video/shared-video.module.ts b/client/src/app/shared/shared-video/shared-video.module.ts
new file mode 100644 (file)
index 0000000..dfac4e3
--- /dev/null
@@ -0,0 +1,19 @@
+
+import { NgModule } from '@angular/core'
+import { SharedMainModule } from '../shared-main/shared-main.module'
+import { VideoViewsCounterComponent } from './video-views-counter.component'
+
+@NgModule({
+  imports: [
+    SharedMainModule
+  ],
+
+  declarations: [
+    VideoViewsCounterComponent
+  ],
+
+  exports: [
+    VideoViewsCounterComponent
+  ]
+})
+export class SharedVideoModule { }
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.html b/client/src/app/shared/shared-video/video-views-counter.component.html
new file mode 100644 (file)
index 0000000..a6679f7
--- /dev/null
@@ -0,0 +1,9 @@
+<span [title]="video.getExactNumberOfViews()">
+  <ng-container i18n *ngIf="!video.isLive">
+    {video.views, plural, =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}
+  </ng-container>
+
+  <ng-container i18n *ngIf="video.isLive">
+    {video.views, plural, =1 {1 viewer} other {{{ video.views | myNumberFormatter }} viewers}}
+  </ng-container>
+</span>
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.scss b/client/src/app/shared/shared-video/video-views-counter.component.scss
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.ts b/client/src/app/shared/shared-video/video-views-counter.component.ts
new file mode 100644 (file)
index 0000000..17e6e37
--- /dev/null
@@ -0,0 +1,11 @@
+import { Component, Input } from '@angular/core'
+import { Video } from '../shared-main'
+
+@Component({
+  selector: 'my-video-views-counter',
+  styleUrls: [ './video-views-counter.component.scss' ],
+  templateUrl: './video-views-counter.component.html'
+})
+export class VideoViewsCounterComponent {
+  @Input() video: Video
+}
index 7ea0ec198e4388bd0fd9b726d315c62545218505..e728fcce0f84e2f7a0b98aac88384703338d01bb 100644 (file)
@@ -42,8 +42,7 @@ import {
   waitJobs,
   waitUntilLiveEnded,
   waitUntilLivePublished,
-  waitUntilLiveSegmentGeneration,
-  waitUntilLog
+  waitUntilLiveSegmentGeneration
 } from '../../../../shared/extra-utils'
 
 const expect = chai.expect
@@ -329,7 +328,7 @@ describe('Test live', function () {
         await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
 
         for (let i = 0; i < resolutions.length; i++) {
-          const segmentNum = 1
+          const segmentNum = 2
           const segmentName = `${i}-00000${segmentNum}.ts`
           await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum)