]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add a loader animation when loading the videos list
authorChocobozzz <florian.bigard@gmail.com>
Thu, 26 May 2016 18:40:03 +0000 (20:40 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 26 May 2016 18:40:03 +0000 (20:40 +0200)
client/angular/videos/components/list/videos-list.component.html
client/angular/videos/components/list/videos-list.component.scss
client/angular/videos/components/list/videos-list.component.ts
client/angular/videos/components/watch/videos-watch.component.html
client/angular/videos/components/watch/videos-watch.component.scss
client/angular/videos/components/watch/videos-watch.component.ts
client/angular/videos/loader.component.html [new file with mode: 0644]
client/angular/videos/loader.component.scss [new file with mode: 0644]
client/angular/videos/loader.component.ts [new file with mode: 0644]
client/tsconfig.json

index 3e30b39b0ad286fa3b33f33699a0454b98c0aace..edbbaf3aeacd735a30e64d326ef20cb89122b6b7 100644 (file)
@@ -4,7 +4,9 @@
 </div>
 
 <div class="videos-miniatures">
-  <div *ngIf="videos.length === 0">There is no video.</div>
+  <my-loader [loading]="loading"></my-loader>
+
+  <div class="col-md-12 no-video" *ngIf="!loading && videos.length === 0">There is no video.</div>
 
   <my-video-miniature *ngFor="let video of videos" [video]="video" [user]="user" (removed)="onRemoved(video)">
   </my-video-miniature>
index 2abc47b1bcc5b62c212fd849c65f883d8325833d..9441d80c3d5bff12346c45afb6cae40f22b6b032 100644 (file)
@@ -1,16 +1,3 @@
-.videos-miniatures {
-  min-height: 600px;
-}
-
-my-videos-miniature {
-  display: inline-block;
-}
-
-pagination {
-  display: block;
-  text-align: center;
-}
-
 .videos-info {
 
   padding-bottom: 20px;
@@ -30,3 +17,21 @@ pagination {
     padding-left: 0;
   }
 }
+
+.videos-miniatures {
+  min-height: 600px;
+
+  my-videos-miniature {
+    display: inline-block;
+  }
+
+  .no-video {
+    margin-top: 50px;
+    text-align: center;
+  }
+}
+
+pagination {
+  display: block;
+  text-align: center;
+}
index 94b064e163aa7654a6ccb4b9863a4518abd117b2..56230e331119d6948f04d0c78a4a6df72388de7b 100644 (file)
@@ -12,12 +12,13 @@ import { VideoMiniatureComponent } from './video-miniature.component';
 import { Search, SearchField } from '../../../app/search';
 import { VideoSortComponent } from './video-sort.component';
 import { SortField } from './sort';
+import { LoaderComponent } from '../../loader.component';
 
 @Component({
   selector: 'my-videos-list',
   styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ],
   templateUrl: 'app/angular/videos/components/list/videos-list.component.html',
-  directives: [ ROUTER_DIRECTIVES, PAGINATION_DIRECTIVES, VideoMiniatureComponent, VideoSortComponent ]
+  directives: [ ROUTER_DIRECTIVES, PAGINATION_DIRECTIVES, VideoMiniatureComponent, VideoSortComponent, LoaderComponent ]
 })
 
 export class VideosListComponent implements OnInit {
@@ -29,6 +30,7 @@ export class VideosListComponent implements OnInit {
     total: 0
   };
   sort: SortField;
+  loading: boolean = false;
 
   private search: Search;
 
@@ -55,6 +57,9 @@ export class VideosListComponent implements OnInit {
   }
 
   getVideos() {
+    this.loading = true;
+    this.videos = [];
+
     let observable = null;
 
     if (this.search.value !== null) {
@@ -67,6 +72,7 @@ export class VideosListComponent implements OnInit {
       ({ videos, totalVideos }) => {
         this.videos = videos;
         this.pagination.total = totalVideos;
+        this.loading = false;
       },
       error => alert(error)
     );
index 9e8f50908d97a374d49626a404378b50feae0b3f..6c36b27e2b76af0a6a6660e1ffa79decd4de6dd9 100644 (file)
@@ -1,7 +1,4 @@
-<!-- Loader -->
-<div id="video-loading" class="col-md-12 text-center" *ngIf="loading">
-  <div class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></div>
-</div>
+<my-loader [loading]="loading"></my-loader>
 
 <div class="embed-responsive embed-responsive-19by9">
 </div>
index 62ae8a1267ba335124eb160742f8d93931f79881..1228d42f44c1c435127b52692059575268e75477 100644 (file)
@@ -2,33 +2,6 @@
   height: 500px;
 }
 
-#video-loading {
-  margin-top: 150px;
-}
-
-// Thanks https://gist.github.com/alexandrevicenzi/680147013e902a4eaa5d
-.glyphicon-refresh-animate {
-    -animation: spin .7s infinite linear;
-    -ms-animation: spin .7s infinite linear;
-    -webkit-animation: spinw .7s infinite linear;
-    -moz-animation: spinm .7s infinite linear;
-}
-
-@keyframes spin {
-    from { transform: scale(1) rotate(0deg);}
-    to { transform: scale(1) rotate(360deg);}
-}
-
-@-webkit-keyframes spinw {
-    from { -webkit-transform: rotate(0deg);}
-    to { -webkit-transform: rotate(360deg);}
-}
-
-@-moz-keyframes spinm {
-    from { -moz-transform: rotate(0deg);}
-    to { -moz-transform: rotate(360deg);}
-}
-
 #torrent-info {
   font-size: 10px;
 
index 6e212e8bc8afa72ec69fa9ba977d434c4ec3a6fd..e551e1f9a1fae1ab45b63478090571bc0e8a9731 100644 (file)
@@ -3,6 +3,8 @@ import { RouteParams, CanDeactivate, ComponentInstruction } from '@angular/route
 
 import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
 
+import { LoaderComponent } from '../../loader.component';
+
 // TODO import it with systemjs
 declare var WebTorrent: any;
 
@@ -13,6 +15,7 @@ import { VideosService } from '../../videos.service';
   selector: 'my-video-watch',
   templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html',
   styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ],
+  directives: [ LoaderComponent ],
   pipes: [ BytesPipe ]
 })
 
diff --git a/client/angular/videos/loader.component.html b/client/angular/videos/loader.component.html
new file mode 100644 (file)
index 0000000..d02296a
--- /dev/null
@@ -0,0 +1,3 @@
+<div id="video-loading" class="col-md-12 text-center" *ngIf="loading">
+  <div class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></div>
+</div>
diff --git a/client/angular/videos/loader.component.scss b/client/angular/videos/loader.component.scss
new file mode 100644 (file)
index 0000000..4541958
--- /dev/null
@@ -0,0 +1,26 @@
+div {
+  margin-top: 150px;
+}
+
+// Thanks https://gist.github.com/alexandrevicenzi/680147013e902a4eaa5d
+.glyphicon-refresh-animate {
+    -animation: spin .7s infinite linear;
+    -ms-animation: spin .7s infinite linear;
+    -webkit-animation: spinw .7s infinite linear;
+    -moz-animation: spinm .7s infinite linear;
+}
+
+@keyframes spin {
+    from { transform: scale(1) rotate(0deg);}
+    to { transform: scale(1) rotate(360deg);}
+}
+
+@-webkit-keyframes spinw {
+    from { -webkit-transform: rotate(0deg);}
+    to { -webkit-transform: rotate(360deg);}
+}
+
+@-moz-keyframes spinm {
+    from { -moz-transform: rotate(0deg);}
+    to { -moz-transform: rotate(360deg);}
+}
diff --git a/client/angular/videos/loader.component.ts b/client/angular/videos/loader.component.ts
new file mode 100644 (file)
index 0000000..2432943
--- /dev/null
@@ -0,0 +1,11 @@
+import { Component, Input } from '@angular/core';
+
+@Component({
+  selector: 'my-loader',
+  styleUrls: [ 'app/angular/videos/loader.component.css' ],
+  templateUrl: 'app/angular/videos/loader.component.html'
+})
+
+export class LoaderComponent {
+  @Input() loading: boolean;
+}
index 270524e5f5dc0833414a6069e51775747db49fdd..8e786ca28cc7ffa671fe820493cbf905016bb80a 100644 (file)
@@ -36,6 +36,7 @@
     "angular/videos/components/list/video-sort.component.ts",
     "angular/videos/components/list/videos-list.component.ts",
     "angular/videos/components/watch/videos-watch.component.ts",
+    "angular/videos/loader.component.ts",
     "angular/videos/pagination.ts",
     "angular/videos/video.ts",
     "angular/videos/videos.service.ts",