Skip to content

Commit

Permalink
refactor: improve ccomponents/modules structure
Browse files Browse the repository at this point in the history
Extracted all related video player components to the own module.
Removed unused components and directives.
  • Loading branch information
4gray committed Dec 18, 2020
1 parent ff0864f commit 4abaeae
Show file tree
Hide file tree
Showing 27 changed files with 52 additions and 99 deletions.
7 changes: 3 additions & 4 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PageNotFoundComponent } from './shared/components';
import { VideoPlayerComponent } from './video-player/video-player.component';

const routes: Routes = [
{
Expand All @@ -11,7 +9,8 @@ const routes: Routes = [
},
{
path: 'iptv',
component: VideoPlayerComponent,
loadChildren: () =>
import('./player/player.module').then((m) => m.PlayerModule),
},
{
path: 'settings',
Expand All @@ -20,7 +19,7 @@ const routes: Routes = [
},
{
path: '**',
component: PageNotFoundComponent,
redirectTo: '',
},
];

Expand Down
14 changes: 1 addition & 13 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AppRoutingModule } from './app-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { FilterPipeModule } from 'ngx-filter-pipe';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { SharedModule } from './shared/shared.module';
Expand All @@ -15,30 +14,19 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { AppComponent } from './app.component';
import { VideoPlayerComponent } from './video-player/video-player.component';
import { ChannelListContainerComponent } from './channel-list-container/channel-list-container.component';
import { VjsPlayerComponent } from './vjs-player/vjs-player.component';
import { HtmlVideoPlayerComponent } from './html-video-player/html-video-player.component';

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
declarations: [
AppComponent,
ChannelListContainerComponent,
VideoPlayerComponent,
VjsPlayerComponent,
HtmlVideoPlayerComponent,
],
declarations: [AppComponent],
imports: [
AppRoutingModule,
BrowserAnimationsModule,
BrowserModule,
CommonModule,
FilterPipeModule,
HttpClientModule,
SharedModule,
TranslateModule.forRoot({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChannelListContainerComponent } from './channel-list-container.component';
import { ChannelQuery } from '../state/channel.query';
import { ChannelStore } from '../state/channel.store';
import { ChannelQuery } from '../../../state/channel.query';
import { ChannelStore } from '../../../state/channel.store';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from '@angular/material/icon';
Expand All @@ -14,8 +14,8 @@ import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { FilterPipeModule } from 'ngx-filter-pipe';
import { By } from '@angular/platform-browser';
import { createChannel } from '../state';
import * as MOCKED_PLAYLIST from '../../mocks/playlist.json';
import { createChannel } from '../../../state';
import * as MOCKED_PLAYLIST from '../../../../mocks/playlist.json';

class MatSnackBarStub {
open(): void {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Channel, ChannelStore, ChannelQuery } from '../state';
import { Component, Input } from '@angular/core';
import { Channel, ChannelStore, ChannelQuery } from '../../../state';

import * as _ from 'lodash';
import { MatSnackBar } from '@angular/material/snack-bar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SimpleChanges,
ViewChild,
} from '@angular/core';
import { Channel } from '../state';
import { Channel } from '../../../state';
import * as Hls from 'hls.js';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { VideoPlayerComponent } from './video-player.component';
import { MockComponent, MockModule } from 'ng-mocks';
import { ChannelListContainerComponent } from '../channel-list-container/channel-list-container.component';
import { ChannelListContainerComponent } from '../../../channel-list-container/channel-list-container.component';
import { VjsPlayerComponent } from '../vjs-player/vjs-player.component';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatIconModule } from '@angular/material/icon';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ChannelStore } from '../state/channel.store';
import * as MOCKED_PLAYLIST from '../../mocks/playlist.json';
import { createChannel } from '../state';
import { ChannelStore } from '../../../state/channel.store';
import * as MOCKED_PLAYLIST from '../../../../mocks/playlist.json';
import { createChannel } from '../../../state';
import { HtmlVideoPlayerComponent } from '../html-video-player/html-video-player.component';

class MatSnackBarStub {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ChannelQuery, Channel, ChannelStore } from '../state';
import { ChannelQuery, Channel, ChannelStore } from '../../../state';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { MatSidenav } from '@angular/material/sidenav';
import { ElectronService } from '../services/electron.service';
import { ElectronService } from '../../../services/electron.service';
import { StorageMap } from '@ngx-pwa/local-storage';
import { Settings, VideoPlayerType } from '../settings/settings.interface';
import {
Settings,
VideoPlayerType,
} from '../../../settings/settings.interface';
import { MatSnackBar } from '@angular/material/snack-bar';

/** Settings key in storage */
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions src/app/player/player.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ChannelListContainerComponent } from './components/channel-list-container/channel-list-container.component';
import { HtmlVideoPlayerComponent } from './components/html-video-player/html-video-player.component';
import { VideoPlayerComponent } from './components/video-player/video-player.component';
import { VjsPlayerComponent } from './components/vjs-player/vjs-player.component';
import { RouterModule, Routes } from '@angular/router';
import { SharedModule } from 'app/shared/shared.module';

const routes: Routes = [{ path: '', component: VideoPlayerComponent }];

@NgModule({
imports: [CommonModule, RouterModule.forChild(routes), SharedModule],
declarations: [
ChannelListContainerComponent,
HtmlVideoPlayerComponent,
VideoPlayerComponent,
VjsPlayerComponent,
],
})
export class PlayerModule {}
1 change: 0 additions & 1 deletion src/app/shared/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './page-not-found/page-not-found.component';
export * from './header/header.component';

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/app/shared/directives/index.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/app/shared/directives/webview/webview.directive.spec.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/app/shared/directives/webview/webview.directive.ts

This file was deleted.

20 changes: 10 additions & 10 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { TranslateModule } from '@ngx-translate/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { PageNotFoundComponent, HeaderComponent } from './components/';
import { WebviewDirective } from './directives/';
import { HeaderComponent } from './components/';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MaterialModule } from 'app/material.module';
import { FilterPipeModule } from 'ngx-filter-pipe';

@NgModule({
declarations: [PageNotFoundComponent, HeaderComponent, WebviewDirective],
declarations: [HeaderComponent],
imports: [
CommonModule,
TranslateModule,
FilterPipeModule,
FlexLayoutModule,
FormsModule,
MaterialModule,
FlexLayoutModule,
ReactiveFormsModule,
TranslateModule,
],
exports: [
TranslateModule,
WebviewDirective,
FormsModule,
MaterialModule,
FilterPipeModule,
FlexLayoutModule,
FormsModule,
HeaderComponent,
MaterialModule,
ReactiveFormsModule,
TranslateModule,
],
})
export class SharedModule {}

0 comments on commit 4abaeae

Please sign in to comment.