Client: add more informations to watch video view
authorChocobozzz <florian.bigard@gmail.com>
Fri, 4 Nov 2016 15:04:50 +0000 (16:04 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Fri, 4 Nov 2016 15:04:50 +0000 (16:04 +0100)
client/src/app/videos/shared/video.model.ts
client/src/app/videos/shared/video.service.ts
client/src/app/videos/video-watch/video-watch.component.html
client/src/app/videos/video-watch/video-watch.component.scss
client/src/app/videos/video-watch/video-watch.component.ts

index 65417f751e6c3b67d2246ca31b1ed275f437b451..873c83ff1b90d2e0495435b81c87a0fd6096ef7c 100644 (file)
@@ -21,6 +21,7 @@ export class Video {
       port = ':' + port;
     }
 
+
     return author + '@' + host + port;
   }
 
index ad855753344a2f289a2713bdda9f46c8b5b62062..b1f6880954d95a8ce309bd53260b140dde231f69 100644 (file)
@@ -22,6 +22,7 @@ export class VideoService {
   getVideo(id: string): Observable<Video> {
     return this.http.get(VideoService.BASE_VIDEO_URL + id)
                     .map(this.restExtractor.extractDataGet)
+                    .map(video_hash => new Video(video_hash))
                     .catch((res) => this.restExtractor.handleError(res));
   }
 
index ddabdc9e9b9dd675e20c8ea5d9eb914db7103bbc..14947da882b2d09499bf18bc9da1d1fd79d45d0c 100644 (file)
@@ -1,23 +1,74 @@
-<div *ngIf="error" class="alert alert-danger">
-  The video load seems to be abnormally long. You could:
-  <ul>
-    <li>Check your browser console to see potentials errors</li>
-    <li>Your firewall or NAT could be too restrictive for WebRTC (there is no TURN server)</li>
-    <li>
-      Report an issue on
-      <a href="https://github.com/Chocobozzz/PeerTube/issues" title="Report an issue">
-        https://github.com/Chocobozzz/PeerTube/issues
-      </a>
-    </li>
-  </ul>
+<div *ngIf="error" class="row">
+  <div class="alert alert-danger">
+    The video load seems to be abnormally long.
+    <ul>
+      <li>Maybe the server {{ video.podUrl }} is down :(</li>
+      <li>
+        If not, you can report an issue on
+        <a href="https://github.com/Chocobozzz/PeerTube/issues" title="Report an issue">
+          https://github.com/Chocobozzz/PeerTube/issues
+        </a>
+      </li>
+    </ul>
+  </div>
 </div>
 
-<div class="embed-responsive embed-responsive-19by9">
-  <my-loader [loading]="loading"></my-loader>
+<div class="row">
+  <div class="col-md-12">
+    <div class="embed-responsive embed-responsive-19by9">
+      <my-loader [loading]="loading"></my-loader>
+    </div>
+  </div>
 </div>
 
-<div id="torrent-info">
+<div id="torrent-info" class="row">
   <div id="torrent-info-download" class="col-md-4 col-sm-4 col-xs-4">Download: {{ downloadSpeed | bytes }}/s</div>
   <div id="torrent-info-upload" class="col-md-4 col-sm-4 col-xs-4">Upload: {{ uploadSpeed | bytes }}/s</div>
   <div id="torrent-info-peers" class="col-md-4 col-sm-4 col-xs-4">Number of peers: {{ numPeers }}</div>
-<div>
+</div>
+
+<div *ngIf="video !== null" id="video-info">
+  <div class="row" id="video-name-actions">
+    <div class="col-md-8">
+      <div class="row">
+        <div id="video-name" class="col-md-12">
+          {{ video.name }}
+        </div>
+      </div>
+
+      <div class="row">
+        <div class="col-md-12" id="video-by-date">
+          <span id="video-by">
+              from
+              <a [routerLink]="['/videos/list', { field: 'author', search: video.author }]" class="video-miniature-author">
+                {{ video.by }}
+              </a>
+            </span>
+          <span id="video-date">on {{ video.createdDate | date:'short' }}</span>
+        </div>
+      </div>
+    </div>
+
+    <div id="video-actions" class="col-md-4 text-right">
+      <button title="Get magnet URI" id="magnet-uri" class="btn btn-default">
+        <span class="glyphicon glyphicon-magnet"></span> Magnet
+      </button>
+    </div>
+  </div>
+
+  <div id="video-tags" class="row">
+    <div class="col-md-12">
+      <a *ngFor="let tag of video.tags" [routerLink]="['/videos/list', { field: 'tags', search: tag }]" class="label label-primary">
+        {{ tag }}
+      </a>
+    </div>
+  </div>
+
+  <div id="video-description" class="row">
+    <div class="col-md-12">
+      <div id="description-label">Description</div>
+      {{ video.description }}
+    </div>
+  </div>
+</div>
+
index 96420582ae831a6051ad39d932275eb021a41997..e1d9300cd625baf64331d6d3bfd5dafb8c2cbebd 100644 (file)
@@ -24,3 +24,56 @@ my-loader {
     height: 300px;
   }
 }
+
+#video-info {
+  border-top: 1px solid rgba(0, 0, 0, 0.1);
+  margin-top: 10px;
+  padding-top: 5px;
+
+  #video-name-actions {
+
+    #video-name {
+      font-size: 20px;
+    }
+
+    .btn .glyphicon {
+      position: relative;
+      top: 2px;
+    }
+
+    #magnet-uri {
+      font-weight: bold;
+      opacity: 0.85;
+    }
+  }
+
+  #video-by-date {
+    font-size: 13px;
+    opacity: 0.6;
+
+    a {
+      color: black;
+    }
+
+    #video-date:before {
+      content: '\002022';
+      margin: 0 5px;
+    }
+  }
+
+  #video-tags {
+    margin-top: 10px;
+
+    a {
+      margin-right: 5px;
+    }
+  }
+
+  #video-description {
+    margin-top: 15px;
+
+    #description-label {
+      font-weight: bold;
+    }
+  }
+}
index 239e24c990e8c82613faa92b4abdeb628c905305..9a36c17e254bb004ca490ea20d361cdab113298d 100644 (file)
@@ -18,7 +18,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   loading: boolean = false;
   numPeers: number;
   uploadSpeed: number;
-  video: Video;
+  video: Video = null;
 
   private errorTimer: NodeJS.Timer;
   private sub: any;
@@ -32,6 +32,28 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     private webTorrentService: WebTorrentService
   ) {}
 
+  ngOnInit() {
+    this.sub = this.route.params.subscribe(routeParams => {
+      let id = routeParams['id'];
+      this.videoService.getVideo(id).subscribe(
+        video => {
+          this.video = video;
+          this.loadVideo();
+        },
+        error => alert(error.text)
+      );
+    });
+  }
+
+  ngOnDestroy() {
+    console.log('Removing video from webtorrent.');
+    clearInterval(this.torrentInfosInterval);
+    clearTimeout(this.errorTimer);
+    this.webTorrentService.remove(this.video.magnetUri);
+
+    this.sub.unsubscribe();
+  }
+
   loadVideo() {
     // Reset the error
     this.error = false;
@@ -65,28 +87,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     });
   }
 
-  ngOnDestroy() {
-    console.log('Removing video from webtorrent.');
-    clearInterval(this.torrentInfosInterval);
-    clearTimeout(this.errorTimer);
-    this.webTorrentService.remove(this.video.magnetUri);
-
-    this.sub.unsubscribe();
-  }
-
-  ngOnInit() {
-    this.sub = this.route.params.subscribe(routeParams => {
-      let id = routeParams['id'];
-      this.videoService.getVideo(id).subscribe(
-        video => {
-          this.video = video;
-          this.loadVideo();
-        },
-        error => alert(error.text)
-      );
-    });
-  }
-
   private loadTooLong() {
     this.error = true;
     console.error('The video load seems to be abnormally long.');