Skip to content

Commit 75a4837

Browse files
committed
2.3 - Implement new loading
1 parent d0f9cf7 commit 75a4837

File tree

9 files changed

+62
-66
lines changed

9 files changed

+62
-66
lines changed

src/app/app.component.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ <h1><span class="favicon-app"></span>YouTube Player v2.0</h1>
1818
<ng-container *ngIf="_shared.isLogged">
1919
<button type="button" (click)="logout()">Logout</button>
2020
</ng-container>
21+
<button type="button" (click)="refresh()">Reinit</button>
2122
<div class="device-bar">
2223
<button type="button" class="trigger-nav" (click)="openMobileMenu()"><span class="fa fa-navicon"></span>Menu</button>
2324
<div id="logo">
@@ -27,7 +28,6 @@ <h1><span class="favicon-app"></span>YouTube Player v2.0</h1>
2728
</div>
2829
</header>
2930
<div id="app-container" [ngClass]="{'light-mode': !darkMode, 'menu-active': menuActive }">
30-
<div class="loading-bar inactive"></div>
3131
<input type="text" class="hide-input" #videoItemIDvalue />
3232
<div class="container">
3333
<div class="col col-1">
@@ -55,7 +55,12 @@ <h1><span class="favicon-app"></span>YouTube Player v2.0</h1>
5555
</div>
5656
<div class="playlist-video-content" [dragula]='"playlistDrag"' [dragulaModel]='playlistVideos' #playlistContainer>
5757
<div *ngIf="playlistVideos.length === 0" class="video-list-info">
58-
Empty playlist
58+
<div *ngFor="let i of [1,2,3,4,5]" class="video-item">
59+
<div class="video-item-info">
60+
<div class="video-item-image loading-featured"></div>
61+
<div class="video-item-content loading-featured"></div>
62+
</div>
63+
</div>
5964
</div>
6065
<div *ngFor="let playlistVideo of playlistVideos; let i = index" [ngClass]="currentPlaylistItem === i ? 'active' : ''" [attr.data-index]="i" class="video-item">
6166
<div class="video-item-info">
@@ -99,11 +104,14 @@ <h2>Player</h2>
99104
<p (click)="addPlaylistItem(0, 3)"><span class="fa fa-plus"></span>Add to playlist</p>
100105
</div>
101106
</div>
107+
<div *ngIf="!currentVideo.id" class="app-content">
108+
<div class="youtube-player active loading-featured"></div>
109+
</div>
102110
<div class="app-content">
103-
<div id="youtube-player" *ngIf="currentVideo.id" [ngClass]="{'active': displayVideoPlayer }">
111+
<div class="youtube-player" *ngIf="currentVideo.id" [ngClass]="{'active': displayVideoPlayer }">
104112
<youtube-player [videoId]="currentVideo.id" (ready)="savePlayer($event)" (change)="onStateChange($event)" [playerVars]="playerVars()"></youtube-player>
105113
</div>
106-
<div *ngIf="currentVideo.id" class="current-video-all">
114+
<div class="current-video-all" *ngIf="currentVideo.id">
107115
<div class="current-video-details">
108116
<p class="current-video-name">{{ currentVideo.title }}</p>
109117
</div>
@@ -139,11 +147,19 @@ <h2>Player</h2>
139147
<input id="shareInput" type="text" name="current video share" #shareInput [value]="shareLink" (click)="copyShareLink(shareInput.select())" readonly>
140148
</div>
141149
</div>
142-
<div id="related-video-list" class="video-list" [ngClass]="{'activePlayer': displayVideoPlayer }">
150+
<div *ngIf="relatedVideos" id="related-video-list" class="video-list" [ngClass]="{'activePlayer': displayVideoPlayer }">
143151
<div class="video-item-head">
144152
Similar videos
145153
</div>
146154
<div class="related-video-content">
155+
<div *ngIf="relatedVideos.length === 0" class="video-list-info">
156+
<div *ngFor="let i of [1,2,3,4]" class="video-item">
157+
<div class="video-item-info">
158+
<div class="video-item-image loading-featured"></div>
159+
<div class="video-item-content loading-featured"></div>
160+
</div>
161+
</div>
162+
</div>
147163
<div *ngFor="let relatedVideo of relatedVideos; let i = index" [attr.data-index]="i" class="video-item">
148164
<div class="video-item-info">
149165
<div *ngIf="thumbnails" class="video-item-image" [ngStyle]="{'background-image': 'url(' + relatedVideo.snippet.thumbnails.default.url +')'}"></div>

src/app/app.component.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ import { DbCrudService } from './services/db-crud.service';
99
import { AuthService } from './services/auth.service';
1010
import { AngularFireAuth } from 'angularfire2/auth';
1111
import { AngularFireDatabase } from 'angularfire2/database';
12+
import { AngularFirestore } from 'angularfire2/firestore';
1213
import * as firebase from 'firebase/app';
1314

1415
import { IRelatedVideo } from './models/related-video.model';
1516
import { INotify } from './models/notify.model';
1617
import { IFeedVideo } from './models/feed-video.model';
18+
import { Observable } from 'rxjs';
1719

1820
@Component({
1921
selector: 'app-yt',
2022
templateUrl: 'app.component.html',
21-
providers: [ AuthService, DbCrudService ]
23+
providers: [ AuthService, DbCrudService, AngularFirestore ]
2224
})
2325

2426
export class AppComponent implements OnInit {
@@ -29,12 +31,12 @@ export class AppComponent implements OnInit {
2931
nw: any;
3032
videoRangePercent = 0;
3133

32-
relatedVideos: Array<IRelatedVideo>;
34+
relatedVideos: Array<IRelatedVideo> = [];
3335
feedVideos: Array<IFeedVideo>;
3436
playlistVideos: Array<any> = [];
3537
tempPlaylist: Array<any> = [];
3638
currentVideoObject: Array<any> = [];
37-
39+
3840
thumbnails = true;
3941
darkMode = true;
4042
menuActive = false;
@@ -91,6 +93,7 @@ export class AppComponent implements OnInit {
9193

9294
private authService: AuthService,
9395
public afAuth: AngularFireAuth,
96+
private db: AngularFirestore,
9497
private db2: AngularFireDatabase,
9598
private dbcrud: DbCrudService
9699
) {
@@ -137,6 +140,7 @@ export class AppComponent implements OnInit {
137140
if (data.length > 0) {
138141
this.currentVideo = data['2'];
139142
this.shareLink = 'https://youtu.be/' + this.currentVideo.id;
143+
this.updatePlaylist();
140144
this.getRelatedVideos();
141145
} else {
142146
this.setDefaultPlayer();
@@ -145,6 +149,14 @@ export class AppComponent implements OnInit {
145149
this.setSettings();
146150
}
147151

152+
refresh() {
153+
console.log('da');
154+
this.currentVideo.id = '';
155+
this.clearSession();
156+
// this.playlistInit();
157+
// this.updatePlaylist();
158+
}
159+
148160
// ---------------- Init player ----------------
149161

150162
savePlayer(player) {
@@ -366,10 +378,17 @@ export class AppComponent implements OnInit {
366378
}
367379

368380
clearPlaylist() {
369-
this.currentPlaylistItem = -1;
370-
this.playlistVideos = [];
371-
this._shared.playlist = [];
372-
this._shared.updatePlaylist();
381+
this.currentPlaylistItem = -1;
382+
this.playlistVideos = [];
383+
this._shared.playlist = [];
384+
this._shared.updatePlaylist();
385+
}
386+
387+
clearSession() {
388+
this.currentPlaylistItem = -1;
389+
this.playlistVideos = [];
390+
this._shared.playlist = [];
391+
this.relatedVideos = [];
373392
}
374393

375394
exportPlaylist() {

src/app/components/category/category.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ng-container>
1515
</div>
1616
<div class="feed-video-list grid-list loading-list">
17-
<div *ngFor="let i of [1,2,3,4]" class="video-item loading-featured-video-item">
17+
<div *ngFor="let i of [1,2,3,4,5,6,7,8,9,10,11,12,13]" class="video-item loading-featured-video-item">
1818
<div class="video-item-info">
1919
<div class="video-item-image"></div>
2020
<div class="video-item-content">

src/assets/scss/_common.scss

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
.loading-app {
2-
position: fixed;
3-
color: var(--c-white);
4-
top: 50%;
5-
left: 50%;
6-
transform: translate(-50%, -50%);
7-
z-index: 10;
8-
}
9-
10-
@keyframes loading-animation {
11-
0% { opacity: 0; }
12-
100% { opacity: 1; }
13-
}
14-
151
@keyframes loading-modal {
162
0% { opacity: 0; top: 60% }
173
100% { opacity: 1; top: 50%; }
@@ -22,35 +8,6 @@
228
justify-content: center;
239
}
2410

25-
.loading-bar {
26-
position: fixed;
27-
margin: 0;
28-
padding: 0;
29-
top: 0;
30-
left: 0;
31-
right: 0;
32-
z-index: 99999;
33-
&:before {
34-
content: '';
35-
display: block;
36-
margin: 0;
37-
padding: 0;
38-
z-index: 99998;
39-
background-color: var(--c-primary);
40-
color: var(--c-primary);
41-
box-shadow: 0 0 10px 0;
42-
height: 2px;
43-
opacity: 0;
44-
width: 0%;
45-
transition: all 0.5s ease-in-out;
46-
}
47-
&.active {
48-
&:before {
49-
animation: loading-animation 2s 1;
50-
}
51-
}
52-
}
53-
5411
.hide {
5512
display: none;
5613
}
@@ -132,9 +89,6 @@
13289
.app-content {
13390
padding: 0 20px;
13491
position: absolute;
135-
.loading-app {
136-
position: absolute;
137-
}
13892
}
13993
}
14094
&-player {
@@ -144,7 +98,7 @@
14498
}
14599
}
146100

147-
#youtube-player {
101+
.youtube-player {
148102
height: 0;
149103
opacity: 0;
150104
transition: opacity 0.1s ease-out, visibility 0.1s ease-out, height 0.1s ease-out 0.1s;

src/assets/scss/_global.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ body {
2121
cursor: default;
2222
-webkit-app-region: no-drag;
2323
overflow: hidden;
24-
animation: loading-animation 2s 1;
2524
}
2625

2726
a,

src/assets/scss/_loading.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@
3636
.loading-list {
3737
width: 100%;
3838
height: 100%;
39+
}
40+
41+
.video-item-content.loading-featured,
42+
.video-item-image.loading-featured {
43+
height: 60px;
44+
}
45+
46+
.youtube-player.loading-featured {
47+
height: 375px;
3948
}

src/assets/scss/_responsive.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
width: calc(100% - 20px);
4545
}
4646

47-
#youtube-player {
47+
.youtube-player {
4848
padding: 0 10px;
4949
}
5050
}

src/assets/scss/_videos.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ iframe {
279279
width: 100%;
280280
overflow: auto;
281281
z-index: 0;
282+
.video-list-info {
283+
margin: 0;
284+
}
282285
&::-webkit-scrollbar-track {
283286
border-radius: 2px;
284287
}

src/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
</head>
1111
<body>
1212
<app-yt>
13-
<div class="loading-app">
14-
<i class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
15-
<span class="sr-only">Loading...</span>
16-
</div>
1713
</app-yt>
1814
</body>
1915
</html>

0 commit comments

Comments
 (0)